Browse Source

Add 'M.py'

webturing 4 years ago
parent
commit
fee9e82482
1 changed files with 12 additions and 0 deletions
  1. 12 0
      M.py

+ 12 - 0
M.py

@@ -0,0 +1,12 @@
+import sys
+def foo(n):
+    if n == 1:
+        return 0
+    if n % 2 == 0:
+        return foo(n / 2) + 1
+    else:
+        return foo(3 * n + 1) + 1
+ 
+for line in sys.stdin.readlines():
+    for n in map(int,line.strip().split()):
+        print foo(n)