N is a base ten integer, let D(N) denote the set of its decimal digits. For example, D(3131663) is {1,3,6}.
Find the first 3 positive integers such that D(N)=D(N²)=D(N³), other than the trivial solutions 1, 10, 100, etc.
D(N), N, N², N³
[0, 1, 2, 4, 5, 6, 7]
4152760
17245415617600
71616072160144576000
[1, 2, 4, 5, 6, 8, 9]
9845261
96929164158121
954292919648546514581
[0, 1, 2, 3, 4, 5, 7, 9]
10253497
105134200729009
1077993211772291594473
----------------------------
def d(n):
""" for integer n, d(n) is the set of digits of n """
return set(str(n))
for n in range(4152760,1000000000):
x = d(n)
if str(n)[0] == '1' and d(int(str(n)[1:])) == {'0'}:
continue
if x == d(n**2) and x == d(n**3):
d_of_n = sorted([int(char) for char in x])
print(d_of_n, n, n**2, n**3)
|
Posted by Larry
on 2024-01-23 12:33:02 |