Created
January 19, 2023 11:17
-
-
Save ishandutta2007/29dbdfce450844940698cf2f3916d6b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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