unsigned long long terms;
unsigned long long test;
unsigned long long digit = 1;
unsigned long long max = 0;
//cout<<sizeof(long)<<" "<<sizeof(int)<<endl;
//cout<<digit<<endl;
for(;digit<1000000;++digit)
{
terms = 1;
test = digit;
while(test>1)
{
if(0==(test%2))
{
test /=2;
}else{
test = test *3 +1;
}
terms ++;
}
if(terms>max)
max = terms;
}
//terms = get_chain_length();
/*if(terms>max)
max = terms;*/
//cout<<sizeof(long long)<<endl;
cout<<max<<endl;
It is out of INT_MAX, how can I correct it? I try to use Hash_map in a recursive way, but stack over.