Challenge:
You are given a base 10 number. For each base from 10 counting down to base 2:
- Take the original input number as a base 10 string, and remove any digits of the number which are invalid for the base.
- Interpret the resulting number string in the that base. If this gives 1 or 0, terminate the whole process.
- Output or print its largest prime factor, as decimal number.
The output can be an array of the largest prime factors.
Sample cases:
Input:
987654321
Output:
379721
10593529
1091
179
1493
293
19
7
Alternately:
[379721,10593529,1091,179,1493,293,19,7]
This prints the largest prime factors of \$987654321\$, \$87654321_9 = 42374116_{10}\$, \$7654321_{8} = 2054353_{10}\$, and so on until it reaches \$1_2\$, where it stops.