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++
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.