I have n of type unsigned long long
and a loop in c/c++
while( n < ULLONG_MAX ){
...
n += revert( n );
}
I need to output the last n before it goes really big, is there a way I can verify and break loop? Because all the time I get outputted big same number but less then ULLONG_MAX
If
nisunsigned long longthenn <= ULLONG_MAXis always true.If you know that
revertalways returns a positive number you can check ifn + revert( n )is< n(i.e., check a wrap around). Or also check thatrevert(n) < ULLONG_MAX - n.