You are viewing a single comment's thread. Return to all comments →
k = gets k = k.to_i answer = 0 m = (10 ** 9) + 7 def isPerfectSquare(n) return true if(n == 1) temp = Math.sqrt(n).floor if( (n - temp**2) == 0) return true end return false end (1..k).each{ | i | sum = 0 art = i.to_s.chars.map(&:to_i) art.each{ |e| sum = sum + (e**2) % m } if(isPerfectSquare(sum)) answer = answer + i end } puts answer
what is wrong with my code? i got result as "Wrong answer" Someone help Please!
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 →
what is wrong with my code? i got result as "Wrong answer" Someone help Please!