OFFSET
1,1
COMMENTS
Every term a(n), except for 3, has the form i9...9 with k >= 0 nines, where i = 1, 2, 4, 5, 7 or 8. Indeed, {1,2,4,5,7,8} are all digits respectively prime to 9. Therefore, every prime, except for p=3, is in one of the progressions i + 9*k. On the other hand, to reach prime(n) using other digits, we need a greater number of them, which contradicts the minimality of a(n). - Vladimir Shevelev, May 07 2013
EXAMPLE
E.g. 599 -> 5 + 9 + 9 = prime 23.
MATHEMATICA
sn[n_, k_] := Nest[FromDigits[Flatten[IntegerDigits[{#, 9}]]] &, n, k]; Join[Prime[Range[4]], Table[p = Prime[n]; sn[Mod[p, 9], Quotient[p, 9]], {n, 5, 28}]] (* Jayanta Basu, Jun 29 2013 *)
PROG
(PARI) a(n) = {my(k=1); my(p=prime(n)); while (sumdigits(k) != p, k++); k; } \\ Michel Marcus, Nov 01 2015
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Patrick De Geest, Oct 15 1999
STATUS
approved
