minimum number of steps from 1 -> n with two operations

Viewed 76

Given a number n, find the minimum number of steps to get from 1 to n using only 2 operations:

  1. Multiply by 2
  2. Divide by 3

Is this possible to get to any n using only these two operations?

1 Answers

If I am understanding this correctly, then no.

If n equaled an integer that was not a power of 2, then you would not be able to reach that as you can't keep multiply 2's to 1 and get a non-power of 2. Dividing by 3 would just change the number to a fraction with a power of 3 in the denominator.

Related