aboutsummaryrefslogtreecommitdiff
path: root/works/life/algorithm-experiment/1.1a.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-09-24 13:41:40 +0800
committercrupest <crupest@outlook.com>2021-09-24 13:41:40 +0800
commit01cf50d0c0bce56a1c2599e6ab77033ce9595450 (patch)
treed527b8891f18421d24edf2b827a4a392858ef4fc /works/life/algorithm-experiment/1.1a.cpp
parent9bf99897b7122d5f6269386be4fe0a215b95313b (diff)
downloadcrupest-01cf50d0c0bce56a1c2599e6ab77033ce9595450.tar.gz
crupest-01cf50d0c0bce56a1c2599e6ab77033ce9595450.tar.bz2
crupest-01cf50d0c0bce56a1c2599e6ab77033ce9595450.zip
import(life): Add algorithm expriments.
Diffstat (limited to 'works/life/algorithm-experiment/1.1a.cpp')
-rw-r--r--works/life/algorithm-experiment/1.1a.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/works/life/algorithm-experiment/1.1a.cpp b/works/life/algorithm-experiment/1.1a.cpp
new file mode 100644
index 0000000..cdc34ab
--- /dev/null
+++ b/works/life/algorithm-experiment/1.1a.cpp
@@ -0,0 +1,17 @@
+#include <iostream>
+
+int main() {
+ int n;
+ std::cin >> n;
+
+ int k = 0;
+
+ while (n != 1) {
+ n = n % 2 ? n * 3 + 1 : n / 2;
+ k++;
+ }
+
+ std::cout << k << std::endl;
+
+ return 0;
+} \ No newline at end of file