I have a question concerning Arithma's code, before i read your code, i thought of a solution similar to Joudi's.
I read your code and I understood it, but my question is why did you chose 2 operations versus 1 ? was it a random thing or not ?
because while trying changing the number of operations (3 vs 1 loops eternally, 4 vs 1 not , 5 vs 1 was looping , ...) when I've reached 8 operations vs 1, the number "fast" behaved like fast = fucntion(fast) , it didn't change through all the loop.
......
while(slow != fast){
slow = next(slow);
fast = next(next(next(next(next(next(next(next(fast))))))));
.......
this how i modified it and like i said fast became as if it was a constant, tried it for about more than 100 numbers (ma 2afda bele :P) and i always got results like that :
Enter a number: 6
36-89
45-89
41-89
17-89
50-89
25-89
29-89
85-89
89-89
slow = 89
:(
and many other similar results.
i don't think this is some coincidence, is it some arithmetic property ?
having that i removed the operation on "fast" numbers in the loop and replaced it in the first operation on "fast" (the one used to initialize fast) and i got this code at the end :
void main(){
uint slow, fast;
cout << "Enter number: ";
cin >> slow;
fast = next(next(next(next(next(next(next(next(next(slow)))))))));
cout<<fast ;
if(fast == 1)
cout << "\n:)";
else
cout << "'n:(";
}
and next() is the same as arithma defined it before.
it seems to be a right code but i don't know why :P