Last updated 2 years ago
Was this helpful?
#include <iostream> using namespace std; void solution(long n){ while(n != 1){ cout << n << " "; if(n % 2 == 0){ n = n / 2; } else{ n = n * 3 + 1; } } cout << 1; } int main() { long input; cin >> input; solution(input); return 0; }