We had a challenge on Multiplicative Persistence here.
As a recap, to get a multiplicative persistence of a number, do these steps:
- Multiply all the digits of a number (in base \$10\$)
- Repeat Step 1 until you have a single digit left.
- Then count the number of iterations.
More here on Numberphile:
- Numberphile "What's special about 277777788888899?"
- Numberphile "Multiplicative Persistence (extra footage)"
See the previous challenge.
Rules
The last challenge was all about seeing the intermediate results, but here:
- The input should be a positive integer \$n\$.
- The output should be the integer with the greatest multiplicative persistence among numbers from \$0\$ to \$n-1\$, choosing the smallest option in case of a tie.
- This is code-golf, so the shortest code wins.
Example
[inp]: 10
[out]: 0
[inp]: 100
[out]: 77
[inp]: 50
[out]: 39
[inp]: 31
[out]: 25
Note: Numbers somewhat randomly chosen.
Good Luck!
10
just9
? \$\endgroup\$n-1
:P \$\endgroup\$