Find a positive number n such that the digits in n * n and n * n * n are all unique and also include all 10 digits.
90*90
8100
90*90*90
729000
99*99
9801
99*99*99
970299
100*100
10000
100*100*100
1000000
since the answer should be n such that the combined number of digits in n * n and n * n * n should not be more than 10, we see that we can stop checking at 99!
for n in range(1,100):
alldigits = []
n2digits = str(n * n)
for d in n2digits:
alldigits.append(int(d))
n3digits = str(n * n * n)
for d in n3digits:
alldigits.append(int(d))
if len(set(alldigits)) == 10:
print(n)
69
we can make the program more efficient by starting at a higher number than 1
40*40
1600
40*40*40
64000
50*50
2500
50*50*50
125000
48*48
2304
48*48*48
110592
47*47
2209
47*47*47
103823
46*46
2116
46*46*46
97336
for n in range(47,100):
alldigits = []
n2digits = str(n * n)
for d in n2digits:
alldigits.append(int(d))
n3digits = str(n * n * n)
for d in n3digits:
alldigits.append(int(d))
if len(set(alldigits)) == 10:
print(n)
69