login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A261271
a(n) = a(n-1)-1+p, where p is the smallest prime number that is not a factor of a(n-1)-1.
1
1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41, 43, 47, 49, 53, 55, 59, 61, 67, 71, 73, 77, 79, 83, 85, 89, 91, 97, 101, 103, 107, 109, 113, 115, 119, 121, 127, 131, 133, 137, 139, 143, 145, 149, 151, 157, 161, 163, 167, 169, 173, 175
OFFSET
1,2
COMMENTS
Alternative definition: a(n) = smallest number > a(n-1) coprime with a(n-1)-1. Therefore, the sequence contains all prime numbers in ascending order.
Except for a(2), all terms are odd.
The sequence comprises the largest terms in A123882 appearing in order.
LINKS
EXAMPLE
a(14)=37 because a(13)=31, the smallest prime not a factor of 30 is p = 7, and 30+7 = 37.
MAPLE
f:= proc(k) local p;
p:= 2;
while k-1 mod p = 0 do p:= nextprime(p) od;
k-1+p
end proc:
A[1]:= 1: A[2]:= 2:
for n from 3 to 100 do A[n]:= f(A[n-1]) od:
seq(A[i], i=1..100); # Robert Israel, Oct 23 2018
PROG
(PARI) p(n)=pp=1; while(n%prime(pp)==0, pp++); prime(pp);
first(m)=my(v=vector(m)); v[1]=1; v[2]=2; for(i=3, m, v[i]=v[i-1]-1+p(v[i-1]-1)); v; /* Anders Hellström, Aug 13 2015 */
CROSSREFS
Sequence in context: A038179 A192489 A161578 * A335284 A308966 A186891
KEYWORD
nonn,easy
AUTHOR
Bob Selcoe, Aug 13 2015
STATUS
approved