Reduce a Number to One
You are given an integer n. In one move, you can either:
Multiply n by 2, or Divide n by 6 (only if it is divisible by 6 without a remainder).
Return the minimum number of moves needed to obtain 1 from n, or return -1 if it's impossible to do so.
Example 1
Input:
1
Output:
0
Example 2
Input:
2
Output:
-1
main.cpp
C++
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat