You are viewing a single comment's thread. Return to all comments →
Python 3 solution:
import decimal n=int(input().strip()) p=int(input().strip()) decimal.getcontext().prec=p+4 total=0 for i in range(2,n+1): if int(i**0.5)!=i**0.5: digits=list(str(decimal.Decimal(i).sqrt()))[:p+1] digits.remove('.') #print(len(digits)) total+=sum(map(int,digits)) print(total)
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #80: Square root digital expansion
You are viewing a single comment's thread. Return to all comments →
Python 3 solution: