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, 876543219 = 4237411610, 76543218 = 205435310, and so on until it reaches 12, where it stops.