Project Euler #80: Square root digital expansion

  • + 1 comment

    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