If you analyze, you’ll find it is better to divide by 2 when available.
So,
dp[n] = 1 + dp[n / 2], when N is even.
When is odd, we have to increase/decrease N by 1 and then divide it by 2.
dp[n] = 2 + min(dp[(n - 1)/2], dp[(n + 1)/2])
This can be solved easily with a recursive solution with the base case, if , then the answer is 0.