aboutsummaryrefslogtreecommitdiff
path: root/01_introductory_problems/weird_algorithm_1068.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--01_introductory_problems/weird_algorithm_1068.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/01_introductory_problems/weird_algorithm_1068.cpp b/01_introductory_problems/weird_algorithm_1068.cpp
new file mode 100644
index 0000000..35cbdfa
--- /dev/null
+++ b/01_introductory_problems/weird_algorithm_1068.cpp
@@ -0,0 +1,12 @@
1#include <iostream>
2
3int main() {
4 long long n;
5 std::cin >> n;
6
7 while (n != 1) {
8 std::cout << n << " ";
9 n = (n % 2) ? n * 3 + 1 : n / 2;
10 }
11 std::cout << 1 << std::endl;
12}

Generated with cgit - Back to sebastiano.tronto.net