|
|
A123882
|
|
a(1)=1, a(2)=2. a(n) = the smallest positive integer that does not occur earlier in the sequence and is coprime to the second-largest term occurring earlier in the sequence.
|
|
3
|
|
|
1, 2, 3, 5, 4, 7, 6, 11, 8, 9, 10, 13, 12, 17, 14, 15, 16, 19, 18, 23, 20, 21, 22, 25, 24, 29, 26, 27, 28, 31, 30, 37, 32, 33, 34, 35, 36, 41, 38, 39, 40, 43, 42, 47, 44, 45, 46, 49, 48, 53, 50, 51, 52, 55, 54, 59, 56, 57, 58, 61, 60, 67, 62, 63, 64, 65, 66, 71, 68, 69, 70, 73
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
Sequence is a permutation of the positive integers.
Let z be the largest term already occurring in the sequence. Except for a(2), z is odd.
When n=z, the sequence is a permutation of the positive integers up to and including z.
Let p be the smallest prime number that is not a factor of z-1. When n>=3, z+1 is coprime to both z and z-1+p.
When n>=5, a(n) is the smallest positive integer not yet having occurred in the sequence that is coprime to a(n-1). (End)
|
|
LINKS
|
|
|
FORMULA
|
For n>=5, where z and p are defined in "Comments":
a(n) = n-1, except for a(z+1) = z-1+p.
a(n) = a(n-1)+1, except for a(z+1) = a(z)+p and a(z+2) = a(z)+2 (here, p can also be defined as the smallest prime that is not a factor of a(z)). (End)
|
|
EXAMPLE
|
The second-largest integer among the first 8 terms of the sequence is 7. Those positive terms not occurring among the first 8 terms form the sequence 8,9,10,12,13,...; of these, 8 is the smallest that is coprime to 7. So a(9)=8.
z=43: a(44)=47 because the smallest prime not a factor of z-1 = 42 is 5, and 42+5 = 47. - Bob Selcoe, Aug 12 2015
|
|
MAPLE
|
N:= 1000: # to get all terms before the first term > N
Next:= Vector(N, i->i+1): Next[N]:= 0:
Prev:= Vector(N, i->i-1):
First:= 3: Prev[3]:= 0:
A[1]:= 1: A[2]:= 2:
Largest:= 2: Second:= 1:
for n from 3 do
p:= First;
while igcd(p, Second) > 1 and p <> 0 do
p:= Next[p];
od:
if p = 0 then break fi;
A[n]:= p;
if Next[p] <> 0 then Prev[Next[p]]:= Prev[p] fi;
if p = First then First:= Next[p] else Next[Prev[p]]:= Next[p] fi;
if p > Largest then
Second:= Largest; Largest:= p
elif p > Second then
Second:= p
fi
od:
|
|
MATHEMATICA
|
f[l_List] := Block[{s = Sort[l][[ -2]], k = 1}, While[GCD[k, s] > 1 || MemberQ[l, k], k++ ]; Append[l, k]]; Nest[f, {1, 2}, 75] (* Ray Chandler, Oct 16 2006 *)
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|