Find a positive integer N such that the digits of N combined with the digits of N^2 and the digits of N^3 are exactly the digits of N^6.
Extra credit: Find additional solutions, other than multiples of 10.
[Edit: I forgot to put my solutions in this post, I put them in my next post above, sorry for the confusion]
I assumed the puzzle is calling for the same number of instances of each digit.
I first checked to see what subset of numbers had the correct numbers of digits to make a solution possible. For 10 digit numbers, the first success was 6812920691.
For different numbers of digits, the left most significant digits started with the same pattern. I left this code in, but commented out.
So, for 3-digit numbers, no need to check 100 to 680; just start at 681.
This number represents the sixth root of 0.1 times some power of 10.
Eliminating 68% of the numbers from the search roughly tripled the speed of the program.
Any solution found will have an infinite number of companion solutions simply by adding an arbitrary number of zeros to the end of n. If n has one extra zero, n^2 has 2, n^3 has 3 thus adding 6 zeros which is the same number of zeros added to n^6.
-------------
start = .1 ** (1/6)
i = 2
for i in range(1,9):
print(i)
for n in range(int(start * 10**i),10**i + 1):
d1 = str(n)
d2 = str(n**2)
d3 = str(n**3)
d6 = str(n**6)
# if len(d1)+len(d2)+len(d3) == len(d6):
# print(n)
# break
if ''.join(sorted(d1+d2+d3)) == ''.join(sorted(d6)):
print(n, n**2, n**3, n**6, '
')
Edited on October 11, 2023, 2:23 pm
|
Posted by Larry
on 2023-10-11 08:57:37 |