Take the number \(192\) and multiply it by each of \(1\), \(2\), and \(3\):
\begin{align} 192 \times 1 &= 192\\ 192 \times 2 &= 384\\ 192 \times 3 &= 576 \end{align}By concatenating each product we get the \(1\) to \(9\) pandigital, \(192384576\). We will call \(192384576\) the concatenated product of \(192\) and \((1,2,3)\).
The same can be achieved by starting with \(9\) and multiplying by \(1\), \(2\), \(3\), \(4\), and \(5\), giving the pandigital, \(918273645\), which is the concatenated product of \(9\) and \((1,2,3,4,5)\).
What is the largest \(1\) to \(9\) pandigital \(9\)-digit number that can be formed as the concatenated product of an integer with \((1,2, \dots, n)\) where \(n \gt 1\)?
The concatenated number must be greater than 918273645, so our seed number \(m\) must start with a 9. \(k\)-digit numbers beginning with 9 will result in \((k+1)\)-digit numbers when multiplied by \(n \in \{2, \ldots, 10\}\). Thus if \(m\) has \(k\) digits, the concatenated product will have \(k + (n-1)(k+1) = n(k+1) - 1\) digits. If \(k = 2\), then the product's digit count is \(5, 8, 11, \ldots\); if \(k = 3\), it's \(7, 11, \ldots\); if \(k = 4\), it's \(9, 14, \ldots\); and if \(k \geq 5\), it's 11 or greater. Therefore, \(m\) has 4 digits and \(n=2\). We can check \(m\) starting from \(9876\) and going downward.
def p38():
for m in range(9876, 9122, -1):
cat = str(m) + str(2*m)
if len(set(cat)) == 9 and '0' not in cat:
return cat