풀스택 개발자 2020. 10. 1. 00:50
#include <string>
#include <vector>

using namespace std;
int solution(int num) {
	long long n = num;
	int answer = 0;
	while (n != 1)
	{
		if (answer >= 500) 
        {
            return -1;
        }
		if (n % 2 == 0)
        {
             n = n/2;
          
        }
		else{
             n = (n * 3) + 1;
        } 
		answer++;
	}
	return answer;
}