Created
August 25, 2020 17:59
-
-
Save Lulzx/9e7ad7b00ea7b8482400e1ad5da9edfc to your computer and use it in GitHub Desktop.
254
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import factorial as fac | |
def f(n: int) -> int: | |
y = 0 | |
for x in map(int, str(n)): | |
y += fac(x) | |
return y | |
def s(n: int) -> int: | |
r = 0 | |
while n: | |
r, n = r + n % 10, n // 10 | |
return r | |
def sf(n: int) -> int: | |
return s(f(n)) | |
def g(n: int) -> int: | |
x = 0 | |
while True: | |
spi = sf(x) | |
if spi is n: | |
return x | |
else: | |
x += 1 | |
def sg(n: int) -> int: | |
return s(g(n)) | |
print(f(342), sf(342), sg(5), g(20)) | |
t = 0 | |
for i in range(1, 21): | |
t += sg(i) | |
print(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment