Pandigital Multiples¶

Any number with five or more digits will have a concatenated product with more than 9 digits. Therefore we only need to check numbers with less than five digits.

In [1]:
from itertools import count

def is_pandigital(s):
    return ''.join(sorted(s)) == "123456789"


pandigitals = dict()
for k in range(1, 10000):
    s = ""
    for n in count(1):
        s += str(k * n)
        if len(s) >= 9:
            break
    
    if is_pandigital(s):
        pandigitals[k] = int(s)
In [2]:
pandigitals
Out[2]:
{1: 123456789,
 9: 918273645,
 192: 192384576,
 219: 219438657,
 273: 273546819,
 327: 327654981,
 6729: 672913458,
 6792: 679213584,
 6927: 692713854,
 7269: 726914538,
 7293: 729314586,
 7329: 732914658,
 7692: 769215384,
 7923: 792315846,
 7932: 793215864,
 9267: 926718534,
 9273: 927318546,
 9327: 932718654}
In [3]:
max(pandigitals.values())
Out[3]:
932718654

Copyright (C) 2025 filifa¶

This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license and the BSD Zero Clause license.