diff options
author | standenboy <standenboy@seacrossedlovers.xyz> | 2024-03-18 13:21:36 +0000 |
---|---|---|
committer | standenboy <standenboy@seacrossedlovers.xyz> | 2024-03-18 13:21:36 +0000 |
commit | c696b4d6ded69074cd08c51b91eabeaeac5823ac (patch) | |
tree | ee8b7ff08580a3bffc237c5b8bac9a8bc26d2516 /comp/work/28 | |
parent | 647d3b98658ddae66882badc508633c9a33eff32 (diff) |
did homework
Diffstat (limited to 'comp/work/28')
-rw-r--r-- | comp/work/28/1.py | 26 | ||||
-rw-r--r-- | comp/work/28/2.py | 10 | ||||
-rw-r--r-- | comp/work/28/3.py | 12 |
3 files changed, 48 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))) diff --git a/comp/work/28/2.py b/comp/work/28/2.py new file mode 100644 index 0000000..5e344e4 --- /dev/null +++ b/comp/work/28/2.py @@ -0,0 +1,10 @@ +def gcf(num1, num2): + while num1 != num2: + if (num1 > num2): + num1 = num1 - num2 + else: + num2 = num2 - num1 + return num1 + + +print(gcf(10, 20)) diff --git a/comp/work/28/3.py b/comp/work/28/3.py new file mode 100644 index 0000000..c72e328 --- /dev/null +++ b/comp/work/28/3.py @@ -0,0 +1,12 @@ +number = 0 +while number < 1 or number > 10: + number = input("enter a postive number: ") + if number > 10: + print("number is too big") + else: + if number < 1: + print("not posative") +c = 1 +for k in range(number-1): + print(c) + c = (c * number - 1 - k) / (k + 1) |