CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
int main() {
unsigned long long int n,num,mx,x,count = 0;
for( n=1 ; n<=1000000 ; n=n+2 ){
x = n;
count = 0;
//cout << n <<" : ";
while( x > 1 ){
x = (x%2 == 0) ? x/2 : x*3+1;
count++;
//cout << x << " ";
}
if(count >= mx){
num = n;
mx = count;
}
//cout << "\n" << count << "\n";
}
cout << "Number: " << num << "\nLength: " << mx;
}
/*
c=(0,0)
for n in range(500009,10**6,10):
x,d=n,0
while(x>1):
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run