Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Eureka numbers
- function IsEureka(x::Int64)
- X = split(string(x), "")
- n = length(X)
- s = 0
- for p = 1:n
- s += parse(Int64, X[p]) ^ p
- if s > x; return false; end
- end
- return s == x
- end
- function main(n::Int64 = 1000000)
- c = 0
- for x = 1:n
- if IsEureka(x); c += 1; end
- end
- return c
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement