project-euler/080_square_root_digital_exp...

26 lines
365 B
Python

#!/usr/bin/env python3
from decimal import *
dn = 103
getcontext().prec = dn
def sumdigs(x):
r = 0
while x:
r, x = r + x % 10, x // 10
return r
def sumsquare(x):
sq = Decimal(x).sqrt()
return sumdigs(int((sq) * 10**(dn - 1)) // 1000)
sm = 0
for i in range(2, 101):
x = sumsquare(i)
sm += x if x >10 else 0
print(sm)