We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have passed 5 test cases can anyone please help how to optimise code for larger input
Enter your code here. Read input from STDIN. Print output to STDOUT
if name=="main":
n=int(input())
def squares(value):
return sum(int(c)**2 for c in str(value))
a=0
for i in range(1,n+1):
if (squares(i)**0.5)==int(squares(i)**0.5):
a+=i
else:
pass
print(a)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square
You are viewing a single comment's thread. Return to all comments →
I have passed 5 test cases can anyone please help how to optimise code for larger input