You are viewing a single comment's thread. Return to all comments →
hey guys, firstly python is magic!, secondly i wrote my python solution but i get the first simple case right and the rest is worng :D, any help.
from decimal import *
import math
Sum = 0
N = int(raw_input())
P = int(raw_input())
for i in range(1, N+1):
if (math.sqrt(i) - int(math.sqrt(i))): getcontext().prec = P Sum+=sum(map(int,str(Decimal(i).sqrt()).split('.')[1]))
print Sum
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 →
hey guys, firstly python is magic!, secondly i wrote my python solution but i get the first simple case right and the rest is worng :D, any help.
from decimal import *
import math
Sum = 0
N = int(raw_input())
P = int(raw_input())
for i in range(1, N+1):
print Sum