fork download
  1. #include <bits/stdc++.h>
  2. #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  3. using namespace std;
  4.  
  5. int Sequence(int n) {
  6. if (n == 1) return 1;
  7. if (n % 2 == 0)
  8. return 1 + Sequence(n / 2);
  9. return 1 + Sequence(3 * n + 1);
  10. }
  11.  
  12. void solve() {
  13. cout << Sequence(9) << endl;
  14.  
  15. }
  16.  
  17. int main() {
  18. solve();
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
20