This is in continuation of
super powerful pandigitals.
Determine all the 0 to 9 pandigital numbers (no leading zeroes) that have the highest power of 7 as factor.
Note: A m to n pandigital number is a positive integer that contains all the digits from m to n and only those digits once each, for example - 12345 is 1 to 5 pandigital but not 1 to 9 pandigital.
I found a single solution: 3891240675
Note that 7^12 is greater than the largest 0 to 9 pandigital.
So check 7^11, 7^10 etc
The highest power of 7 I found was 8, 7^8 = 5764801 and only one pandigital (above) had this as a factor.
Here are those with power: 8, 7, and 6:
pandigital power of 7
3891240675 8
3891240675 7
9487215360 7
1428376509 6
1659203847 6
2068975314 6
2980637415 6
3092874561 6
3450762819 6
3492057618 6
3517469802 6
3568294170 6
3891240675 6
4137950628 6
4785961320 6
5361970824 6
5493267108 6
5961274830 6
5971863240 6
6108453729 6
6170925348 6
6290574381 6
6519284037 6
6710934258 6
6917408253 6
7250943168 6
7506123849 6
7598243016 6
8014367529 6
8046132759 6
8365902741 6
9120856374 6
9280741365 6
9350624871 6
9487215360 6
9530627841 6
9617452803 6
--------------------
def ispandigital(n):
""" output True if n is pandigital in base 10 and contains each digit only once """
s = str(n)
if len(s) == 10 and len(set(s)) == 10:
return True
else:
return False
lo = 1023456789
hi = 9876543210
my_base = 7
for power in range(11,5,-1):
factor = my_base**power
if (lo/factor)%1 == 0:
lowMult = int(lo/factor)
else:
lowMult = 1 + int(lo/factor)
highMult = int(hi/factor)
multipliers = [i for i in range(lowMult,highMult+1)]
for m in multipliers:
if ispandigital(m * factor):
print(m * factor, power)
|
Posted by Larry
on 2023-03-08 13:39:18 |