summaryrefslogtreecommitdiff
path: root/introductory_problems/weird_algorithm.cpp
blob: d8f42c39a08f4b9945a60b3f04d8c476477b9ec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// 1608. Weird Algorithm
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long num;
  scanf("%lld", &num);
  while (num > 1) {
    printf("%lld ", num);
    num = num & 1 ? 3 * num + 1 : num / 2;
  }
  printf("1\n");
}