function solution(n) {
let ans = 9999;
let count = 1;
go_dfs(n, count);
function go_dfs(n, count) {
if (n === 1) {
if(count < ans) ans = count;
return;
}
if (n % 2 === 0) {
go_dfs(n / 2, count);
} else {
count++;
go_dfs(n - 1, count);
}
}
return ans;
}
const n = 5000;
solution(n);