diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-05-06 23:24:22 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-05-06 23:24:22 +0200 |
| commit | 9dce6eaf425178ab1c37dc15b3a74f09e23e9243 (patch) | |
| tree | b5897bda0f49f15b0d6d96d470e10603e2220189 /python | |
| parent | ed4b0690e4ee35278bb656c703bd0a1ab102222f (diff) | |
| download | competitive-programming-9dce6eaf425178ab1c37dc15b3a74f09e23e9243.tar.xz competitive-programming-9dce6eaf425178ab1c37dc15b3a74f09e23e9243.zip | |
Added contests file
Diffstat (limited to 'python')
| -rwxr-xr-x | python/RecursiveDigitSum.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/python/RecursiveDigitSum.py b/python/RecursiveDigitSum.py new file mode 100755 index 0000000..98a808d --- /dev/null +++ b/python/RecursiveDigitSum.py @@ -0,0 +1,15 @@ +#!/bin/env/python3 +x,n = map(int, input().split()) +x = str(x) +x = x * n +print(x) +def recursive_digit_sum(x): + y = 0 + if len(x) == 1: + return x; + else: + for i in x: + y += int(i) + print("y: ", y) + return recursive_digit_sum(str(y)) +print(recursive_digit_sum(x)) |
