OFFSET
1,2
COMMENTS
The sequence is started with a(1) = 1 and always extended with the smallest integer not yet present and not leading to a contradiction. The sequence is a permutation of the positive integers.
From Bernard Schott, May 15 2019: (Start)
1, p_1, p_2, p_3, c_1, p_4, c_2, p_5, c_3, p_6, c_4, p_7, ...
At the 4th term, begins the alternating pattern:
{p_3, c_1, p_4, c_2, p_5, c_3, ..., p_(m+2), c_m, ...}.
The terms with odd index are 1, p_2, c_1, c_2, c_3, c_4, c_5, ...;
the terms with even index are p_1, p_3, p_4, p_5, p_6, p_7, ... This is A045344. (End)
LINKS
FORMULA
From Bernard Schott, May 15 2019: (Start)
n odd: a(1) = 1, a(3) = 3, and for n >= 5, a(n) = A002808((n-3)/2).
n even: a(2) = 2, for n >= 4, a(n) = A000040(n/2 + 1), also,
n even: a(n) = A045344(n/2). (End)
For n > 4, if a(n-1) is prime then a(n) is the smallest composite > a(n-2); otherwise a(n) is the smallest prime > a(n-2). - Bill McEachen, Apr 27 2024
EXAMPLE
In the 1st pair of integers (1,2) the larger term is (2), which is prime;
in the 2nd pair of integers (2,3) the larger term is (3), which is prime;
in the 3rd pair of integers (3,5) the larger term is (5), which is prime;
in the 4th pair of integers (5,4) the larger term is (5), which is prime;
in the 5th pair of integers (4,7) the larger term is (7), which is prime;
in the 6th pair of integers (7,6) the larger term is (7), which is prime; etc.
MATHEMATICA
a = {1}; Do[k = 1; While[Nand[PrimeQ@ Max[a[[n - 1]], k], ! MemberQ[a, k]], k++]; AppendTo[a, k], {n, 2, 120}]; a (* Michael De Vlieger, Feb 20 2017 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Eric Angelini and Jean-Marc Falcoz, Feb 20 2017
STATUS
approved