Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #3929 https://kpolyakov.spb.ru/school/ege/gen.php?action=viewAllEgeNo&egeId=16&cat44=on&cat45=on&cat46=on&cat181=on
- def f(s):
- answ = sum(map(int, s))
- if answ < 10:
- return answ
- return f(str(answ))
- #еще один вариант -- нерекурсивный
- def f1(s):
- cur = s
- while len(cur) > 1:
- cur = str(sum(map(int, cur)))
- return cur
- answ = 0
- for x in range(10, 100):
- answ += f(str(x))
- print(answ)
Advertisement
Add Comment
Please, Sign In to add comment