diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-04-30 01:13:40 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-04-30 01:13:40 +0200 |
| commit | a0d7b8320a8996eee0ed957b79c3a882f8b47146 (patch) | |
| tree | 76242ae2b19bad00796ed6d0104da8a0e4a99abe /RecursiveDigitSum.py | |
| download | competitive-programming-a0d7b8320a8996eee0ed957b79c3a882f8b47146.tar.xz competitive-programming-a0d7b8320a8996eee0ed957b79c3a882f8b47146.zip | |
Added all current problems
Diffstat (limited to 'RecursiveDigitSum.py')
| -rw-r--r-- | RecursiveDigitSum.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/RecursiveDigitSum.py b/RecursiveDigitSum.py new file mode 100644 index 0000000..4d7dbd7 --- /dev/null +++ b/RecursiveDigitSum.py @@ -0,0 +1,14 @@ +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)) |
