OFFSET
1,2
COMMENTS
The sequence uses a similar selection rule to the Yellowstone permutation A098550 but instead of choosing the smallest number that has not occurred earlier that has a common factor with a(n-2) and no common factor with a(n-1), the number closest to a(n-2) that satisfies these rules is selected for a(n). If two such numbers are the same distance from a(n-2) then the smaller is chosen.
Many terms are clustered along a line with gradient approximately 1.33. However, along this line the terms often rapidly drop to much smaller values before returning to the main line. More interesting is the existence of regions on the same line where the terms split and form two lines of constantly increasing values. These lines continue until they both start decreasing again to rejoin near the original line.
In the first 15 million terms the maximum number of consecutive increasing terms is seven. This run starts at n = 47685. The maximum number of consecutive decreasing terms is also seven. This starts at n = 4134621.
In the first 15 million terms the fixed points, other than the first three terms, are 4, 323, 516718, 2199679, 2401224. As the terms for larger n seem to drop below the a(n)=n line on numerous occasions, it is possible that more exist, although this is unknown. The smallest number not appearing is 6, although other small values appear after many terms, e.g. a(4946191) = 23. It is unknown if all values eventually appear. The largest change in consecutive terms is from a(399922)=527754 to a(399923)=2887, a difference of 524867.
See also A340783 where the next term is the closest to a(n-1).
LINKS
Scott R. Shannon, Table of n, a(n) for n = 1..10000.
Scott R. Shannon, Image of the first 500 thousand terms. The green line is a(n)=n.
Scott R. Shannon, Image of the first 15 million terms. The green line is a(n)=n.
Rémy Sigrist, PARI program for A340807
EXAMPLE
a(5) = 9 as a(5-2) = a(3) = 3 so a(5) must have 3 as a factor, but cannot be 6 = 3*2 as it cannot have a common factor with a(5-1) = a(4) = 2.
a(12) = 16 as a(12-2) = a(10) = 12 so a(12) must have 2 or 3 as a factor, but cannot have a common factor with a(12-1) = a(11) = 25 = 5*5. The closest numbers to a(12-2) = a(10) = 12 which have 2 or 3 as a factor but not 5 are 8,9,14,16. The first three have already appeared so a(12) = 16.
PROG
(PARI) See Links section.
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Scott R. Shannon, Jan 22 2021
STATUS
approved