login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Start with n; add to it any of its digits; repeat; a(n) = minimal number of steps needed to reach a prime.
12

%I #21 Jul 25 2020 18:38:21

%S 1,0,0,3,0,2,0,2,2,1,0,1,0,2,2,1,0,1,0,6,1,5,0,4,2,3,1,5,0,6,0,2,5,1,

%T 2,4,0,1,3,4,0,4,0,3,2,3,0,2,1,5,2,2,0,1,4,1,4,3,0,3,0,3,3,3,1,2,0,2,

%U 4,4,0,1,0,2,4,1,3,3,0,4,1,3,0,2,3,2,2

%N Start with n; add to it any of its digits; repeat; a(n) = minimal number of steps needed to reach a prime.

%C a(n) = 0 iff n is a prime.

%C Is it a theorem that a(n) always exists?

%C Yes: the proof is similar to that of _Robert Israel_ for A241180. - _Rémy Sigrist_, Jul 25 2020

%D Eric Angelini, Posting to Sequence Fans Mailing List, Apr 20 2014

%H Hiroaki Yamanouchi, <a href="/A241181/b241181.txt">Table of n, a(n) for n = 1..100000</a>

%e Examples, in condensed notation:

%e 1+1=2

%e 2

%e 3

%e 4+4=8+8=16+1=17

%e 5

%e 6+6=12+1=13

%e 7

%e 8+8=16+1=17

%e 9+9=18+1=19

%e 10+1=11

%e 11

%e 12+1=13

%e 13

%e 14+4=18+1=19

%e 15+1=16+1=17

%e 16+1=17

%e 17

%e 18+1=19

%e 19

%e 20+2=22+2=24+2=26+6=32+2=34+3=37

%e ...

%t A241181[n_] := Module[{c, nx},

%t If[PrimeQ[n], Return[0]];

%t c = 1; nx = n;

%t While[ ! AnyTrue[nx = Flatten[nx + IntegerDigits[nx]], PrimeQ], c++];

%t Return[c]];

%t Table[A241181[i], {i, 100}] (* _Robert Price_, Mar 17 2019 *)

%Y Related sequences: A241173, A241174, A241175, A241176, A241177, A241178, A241179, A241180, A241181, A241182, A241183.

%K easy,nonn,base

%O 1,4

%A _N. J. A. Sloane_, Apr 23 2014

%E a(23)-a(87) from _Hiroaki Yamanouchi_, Sep 05 2014