HackerEarth's basic programming solutions( Conject-It !, Play with numbers, Divisibility ) :
Problem 33: Conject-It ! Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { long long n , t ; cin >> t >> n ; while ( t --) { while ( 1 ) // means infinite loop { if ( n == 1 ) { cout << "YES" << endl ; break ; } if ( n % 2 == 0 ) { n = n / 2 ; } else { n =( 3 * n )+ 1 ; } } } } Are you guys wondering why i haven't included the statement cout<<"NO"<<endl; in case n doesn't become equal to 1 in the last operation. If yes then , n will never become other than 1 in last operation. You can take any number and try it yourself. Reason: If n becomes odd , we convert it into even by this operation: n =( 3 * n )+ 1 and if even we divide it by 2 which eventually gives us 1 in the end. Problem 34: Play with numbers Solution: (in c+