function solution(num) {
let result = 0;
if (num === 1) return 0;
for (let i = 0; i < 8000000; i++) {
if (i === 500) return -1;
if (num % 2 === 0) {
num = num / 2;
result += 1;
if (num === 1) {
return result;
}
} else if (num % 2 !== 0) {
num = num * 3 + 1;
result += 1;
if (num === 1) {
return result;
}
}
}
return result;
}