Determine all possible value(s) of a positive duodecimal integer N, such that N and N^4 together contain precisely nine digits from 0 to 9 which are all different. Neither N nor N^4
can contain any leading zero.
I found a single solution
duodecimal N=45.
First, I determine the smallest and largest decimal integers which will yield a combined 9 digits when N and N^4 (in base 12) are concatenated.
base 10 12 12
smallest 42 36 1060900
largest 77 65 B933241
53 45 2786301
Base 10: n=53, n^4=7890481
Base 12: N=45, N^4=2786301
-----------
def digitcount(n):
a = base2base(n,10,12)
b = base2base(n**4,10,12)
return len(a+b)
oldL = 0
newL = 0
for n in range (10000):
newL = digitcount(n)
if oldL < 9 and newL == 9:
print('smallest', n, base2base(n,10,12), base2base(n**4,10,12))
low = n
if oldL == 9 and newL > 9:
print('largest', n-1, base2base(n-1,10,12), base2base((n-1)**4,10,12))
high = n-1
oldL = newL
print()
for n in range (low, high+1):
a = base2base(n,10,12)
b = base2base(n**4,10,12)
c = a+b
if len(c) != len(set(c)):
continue
if 'A' in c or 'B' in c:
continue
print(n, a, b)
|
Posted by Larry
on 2024-07-06 10:23:55 |