summaryrefslogtreecommitdiff
path: root/comp/work/28/1.py
diff options
context:
space:
mode:
Diffstat (limited to 'comp/work/28/1.py')
-rw-r--r--comp/work/28/1.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/comp/work/28/1.py b/comp/work/28/1.py
new file mode 100644
index 0000000..5c8598c
--- /dev/null
+++ b/comp/work/28/1.py
@@ -0,0 +1,26 @@
+def addative(num):
+ if len(num) >= 2:
+ new = 0
+ for i in num:
+ new = new + int(i)
+ return 1 + addative(str(new))
+ else:
+ return 0
+
+
+def multiplative(num):
+ if len(num) >= 2:
+ new = 1
+ for i in num:
+ new = new * int(i)
+ return 1 + addative(str(new))
+ else:
+ return 0
+
+
+num = input("number: ")
+
+if input("m/a: ") == "m":
+ print(multiplative(str(num)))
+else:
+ print(addative(str(num)))