A hard function/sequence
Source: AIME 2004 #15
November 27, 2005
AMCAIMEfunction
Problem Statement
For all positive integers , let
f(x) \equal{} \begin{cases}1 & \text{if }x \equal{} 1 \\
\frac x{10} & \text{if }x\text{ is divisible by 10} \\
x \plus{} 1 & \text{otherwise}\end{cases}and define a sequence as follows: x_1 \equal{} x and x_{n \plus{} 1} \equal{} f(x_n) for all positive integers . Let be the smallest such that x_n \equal{} 1. (For example, d(100) \equal{} 3 and d(87) \equal{} 7.) Let be the number of positive integers such that d(x) \equal{} 20. Find the sum of the distinct prime factors of .