Skip to content

Instantly share code, notes, and snippets.

@ishandutta2007
Created January 19, 2023 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishandutta2007/29dbdfce450844940698cf2f3916d6b8 to your computer and use it in GitHub Desktop.
Save ishandutta2007/29dbdfce450844940698cf2f3916d6b8 to your computer and use it in GitHub Desktop.
function g(n, s)
n ≤ s && return n == s
for i in 1:ndigits(n)-1
g(n % 10^i, s - n ÷ 10^i) && return true
end
false
end
T(N) = sum(n^2 for n in 2:isqrt(N) if g(n^2, n))
@show @time T(10^12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment