2019-08-31 07:22:15 +02:00
|
|
|
from decimal import *
|
|
|
|
|
2019-08-16 05:26:47 +02:00
|
|
|
|
|
|
|
def euler_080():
|
2019-08-31 07:22:15 +02:00
|
|
|
# XXX: totally cheated by using decimal library.
|
|
|
|
def strsum(s):
|
|
|
|
return sum(map(int, s))
|
|
|
|
|
|
|
|
getcontext().prec = 200
|
|
|
|
r = 0
|
|
|
|
for n in range(1, 101):
|
|
|
|
b = str(Decimal(n).sqrt()).replace(".", "")[:100]
|
|
|
|
if len(b) == 100:
|
|
|
|
r += strsum(b)
|
|
|
|
return r
|
2019-08-16 05:26:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print("e080.py: " + str(euler_080()))
|
2019-08-31 07:22:15 +02:00
|
|
|
assert(euler_080() == 40886)
|