login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A241180 Start with n; add to it any of its digits; repeat; a(n) = minimal number of steps needed to reach a prime greater than n. 12

%I #21 Mar 18 2019 08:09:05

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

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

%U 4,4,2,1,2,2,4,1,3,3,3,4,1,3,3,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 greater than n.

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

%C Yes: as long as nonzero digits are used, eventually you reach a number x starting with 10, large enough that there is a prime between x and 3*x/2. All the numbers from x to 3*x/2 start with 1, so if you use the digit 1 you will eventually reach a prime. - _Robert Israel_, Mar 17 2019

%C A variant of this (A241181) sets a(n) = 0 if n is already a prime.

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

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

%e Examples, in condensed notation:

%e 1+1=2

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

%e 3+3=6+6=12+1=13

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

%e 5+5=10+1=11

%e 6+6=12+1=13

%e 7+7=14+4=18+1=19

%e 8+8=16+1=17

%e 9+9=18+1=19

%e 10+1=11

%e 11+1=12+1=13

%e 12+1=13

%e 13+3=16+1=17

%e 14+4=18+1=19

%e 15+1=16+1=17

%e 16+1=17

%e 17+1=18+1=19

%e 18+1=19

%e 19+9=28+8=36+3=39+9=48+8=56+5=61

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

%e ...

%p g:= proc(n,Nmax) option remember; local L,d,t;

%p if isprime(n) then return 0 fi;

%p if n > Nmax then return infinity fi;

%p L:= convert(convert(n,base,10),set) minus {0};

%p 1 + min(seq(procname(n+d),d=L));

%p end proc:

%p f:= proc(n,Nmax) local L,d,t;

%p L:= convert(convert(n,base,10),set) minus {0};

%p 1 + min(seq(g(n+d, Nmax),d=L))

%p end proc:

%p map(f, [$1..200], 1000); # _Robert Israel_, Mar 17 2019

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

%t c = 1; nx = n;

%t While[ !

%t AnyTrue[nx = Flatten[nx + IntegerDigits[nx]],

%t PrimeQ [#] && # > n &], c++];

%t Return[c]];

%t Table[A241180[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,2

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

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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 16:28 EDT 2024. Contains 371254 sequences. (Running on oeis4.)