Using a computer/program, can anyone figure out:
The square of 567 is 321,489. These two numbers contain each of the digits from 1 to 9 exactly once between them. What other three-digit number and its square have this property?
And also explain how?
Using a computer/program, can anyone figure out:
The square of 567 is 321,489. These two numbers contain each of the digits from 1 to 9 exactly once between them. What other three-digit number and its square have this property?
And also explain how?
The key here is that you can use a computer program. The easiest way to do this is using Python. First, create a function that turns the number into a list of digits, like so:
Now, let's say our three-digit number is $a$. We can then combine the digits of $a$ with the digits of $a^2$ using list concatenation:
Finally, we need to make sure
all_digitscontains all the digits from $1$ through $9$. The easiest way to do this is to sort them and to see if it is the array $1, 2, 3, 4, ..., 9$:Finally, we need to loop $a$ from $100$ to $999$ to get through all the three-digit numbers. We can do this with a
forloop, so the full program becomes:This prints out $567$ and $854$, so the final answer is $854$.