login
A089750
a(n) = the first prime in the orbit of n under f(n) = n + the first prime > n, or 0 if no such prime exists.
1
3, 2, 3, 43, 5, 13, 7, 19, 43, 379, 11, 113, 13, 31, 18749, 2341, 17, 37, 19, 43, 379, 788941, 23, 53, 113, 241, 511213, 4089763, 29, 61, 31, 18749, 2341, 71, 601, 73, 37, 79, 163, 331, 41, 353, 43, 379, 788941, 403941973, 47, 101, 13499, 103, 211
OFFSET
1,1
COMMENTS
Note that a(n) = n when n is prime.
Question: Is a(n) > 0 for all n? I do not have a value for a(46).
a(46)=403941973, a(52)=31626333786385669717. - Michel Marcus, May 19 2013
LINKS
EXAMPLE
4 -> 4 + (first prime > 4) = 4 + 5 = 9 -> 9 + 11 = 20 -> 20 + 23 = 43 (prime). So a(4) = 43.
MAPLE
f:= proc(n) local k;
k:= n;
while not isprime(k) do k:= k + nextprime(k) od;
k
end proc:
map(f, [$1..100]); # Robert Israel, Sep 04 2018
MATHEMATICA
a[n_] := NestWhile[# + NextPrime[#]&, n, CompositeQ];
Array[a, 100] (* Jean-François Alcover, Aug 26 2020 *)
PROG
(PARI) a(n) = {while(! isprime(n), n = n + nextprime(n+1); ); return (n); } \\ Michel Marcus, May 19 2013
CROSSREFS
Sequence in context: A248244 A139170 A139075 * A109591 A143932 A304496
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Jan 08 2004
EXTENSIONS
More terms from Michel Marcus, May 19 2013
STATUS
approved