Pandigital Squares
September 29, 2020
A pandigital number, like 4730825961, is a ten-digit number in which each digit from zero to nine appears exactly once. A square number, like 25² = 625, is a number with an integral square root.
Your task is to write a program that finds all of the pandigital square numbers. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Cute little exercise. Here is my take on it in Julia 1.5: https://pastebin.com/XV0aiT9j
Please excuse the unnecessary use of semicolons here. I’ve gotten into the habit of using them everywhere, ever since I started learning another language that requires them. Cheers!
No need to test all integers from 35000 to 100000. Since all pandigitals are divisible by 9, we only need test integers divisible by 3 and exclude those ending in 0
@Ernie. Good point! I’ve amended my code to take into account this information. Thank you for the tip!
Here’s a solution in C.
Output:
Here’s a solution in OCaml.
Output:
Some Golang, very zippy so I didn’t make any extra optimizations: https://pastebin.com/bJwdAHw9