Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pandigital squares drill
- const digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
- function is_pandigital(n::Integer)::Bool
- n_string = string(n);
- if length(n_string) != 10; return false; end
- for digit in digits
- if !contains(n_string, digit); return false; end
- end
- true
- end
- function main()
- a = floor(Int64, sqrt(1000000000)); # no point testing numbers less than this one
- b = floor(Int64, sqrt(9999999999)); # no point testing numbers larger than this one
- for i = a:b
- n = i^2;
- if (n % 3 == 0) && (n % 10 != 0) # expediting process by mitigating search space...
- is_pandigital(n) && println(n)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement