aboutsummaryrefslogtreecommitdiff
path: root/01_introductory_problems/weird_algorithm_1068.cpp
blob: 35cbdfae95c07ed0234e1d46f0200dbfda5968c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

int main() {
	long long n;
	std::cin >> n;

	while (n != 1) {
		std::cout << n << " ";
		n = (n % 2) ? n * 3 + 1 : n / 2;
	}
	std::cout << 1 << std::endl;
}

Generated with cgit - Back to sebastiano.tronto.net