#include <iostream> using namespace std; unsigned long int counter; void Count(unsigned int a) { counter = 1; while(a!=1) { if(a%2) a = (a*3)+1; else a /= 2; counter++; } } int main() { unsigned int maxim[2] = {0, 0}; for(unsigned int i=999999; i>=1; i--) { Count(i); if(counter>maxim[0]) { maxim[0] = counter; maxim[1] = i; } } cout << "Max: " << maxim[0] << " Number: " << maxim[1] << endl; return 0; }