login
A241082
a(n) = n for 1 and prime numbers. For composite numbers, first prime term in sequence starting with n and each time adding smallest prime number not a divisor of the preceding term.
0
1, 2, 3, 7, 5, 11, 7, 11, 11, 13, 11, 17, 13, 17, 17, 19, 17, 23, 19, 23, 23, 29, 23, 29, 29, 29, 29, 31, 29, 37, 31, 37, 37, 37, 37, 41, 37, 41, 41, 43, 41, 47, 43, 47, 47, 53, 47, 53, 53, 53, 53, 59, 53, 59, 59, 59, 59, 61, 59, 67, 61, 67, 67, 67, 67, 71
OFFSET
1,2
EXAMPLE
a(22) = 29 because the smallest prime number not a divisor of 22 is 3, and 22+3=25, and 25 is composite, and the smallest prime number not a divisor of 25 is 2, and 25+2=27, and 27 is composite, and the smallest prime number not a divisor of 27 is 2, and 27+2=29, a prime number.
PROG
(PARI) a(n) = {if ((n==1) || isprime(n), return(n)); k = n; while (! isprime(k), p = 2; while (! (k % p), p = nextprime(p+1)); k += p; ); k; } \\ Michel Marcus, Apr 27 2014
CROSSREFS
Sequence in context: A087572 A085107 A358242 * A219789 A034694 A050921
KEYWORD
nonn
AUTHOR
J. Lowell, Apr 15 2014
EXTENSIONS
More terms from Michel Marcus, Apr 27 2014
STATUS
approved