

A339557


a(0) = 0, a(1) = 1; for n > 1, a(n) = a(n1)  n if a(n) is nonnegative, not already in the sequence, and gcd(a(n1),n) > 1 or gcd(a(n2),n) = 1. Otherwise a(n) = a(n1) + n.


2



0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 31, 42, 30, 17, 31, 16, 32, 15, 33, 14, 34, 55, 77, 54, 78, 53, 79, 52, 24, 53, 83, 114, 82, 115, 149, 184, 148, 111, 149, 188, 228, 187, 229, 186, 142, 187, 233, 280, 232, 281, 331, 382, 330, 277, 331, 276, 220, 277, 335, 394, 334, 273, 335, 398, 462, 397
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,3


COMMENTS

This sequence is a variation of the Recamán sequence A005132 where the same rules apply except an additional restriction is added whereby a(n) = a(n1)  n can occur only if gcd(a(n1),n) > 1 or gcd(a(n2),n) = 1, where gcd is the greatest common divisor. This additional restriction is inspired by the selection rules of A336957 and A098550.
The sequence shows large variations in its values; the bifurcated pattern typical of the Recamán sequence is present but there are regions where the terms rapidly spike up to huge values only to return to smaller values quickly again. For example after 37 million terms a value of ~1.6*10^12 is reached, but just after 41 million terms values below 10000 are again present. See the linked images.
It is unclear if all values are eventually visited; numerous small values like 4 and 5 have not occured after 100 million terms.


LINKS

Table of n, a(n) for n=0..65.
Scott R. Shannon, Image of the terms for n=1 to 1000. The peak value is a(999) = 11794.
Scott R. Shannon, Image of the terms for n=1 to 1000000. The peak value is a(327047) = 149919884.
Scott R. Shannon, Image of the terms for n=1 to 20000000. The peak value is a(9923735) = 808851831874. This is over 5000 times larger than the peak value of the first one million terms, the later being unnoticeable at this scale.
Scott R. Shannon, Image of the terms for n=1 to 50000000. The peak value is a(37076766) = 1695632131873.


EXAMPLE

a(4) = 2. As gcd(a(3),4) = gcd(6,4) = 2 > 1, and as 6  4 = 2 has not occurred previously, a(4) = 2.
a(10) = 31. a(9) = 21, and 21  10 = 11 has not occurred previously. However as gcd(a(9),10) = gcd(21,10) = 1, and gcd(a(8),10) = gcd(12,10) = 2 > 1, both additional criteria for subtraction fail, thus a(10) = a(9) + 10 = 21 + 10 = 31. This is the first term which differs from the standard Recamán sequence A005132.


MATHEMATICA

Block[{a = {0, 1}, k = 1}, Do[AppendTo[a, If[And[# > 0, FreeQ[a, #], Or[GCD[a[[1]], i] > 1, GCD[a[[2]], i] == 1 ]], #, a[[1]] + i] &[a[[1]]  i]], {i, 2, 10^4}]; a] (* Michael De Vlieger, Dec 09 2020 *)


CROSSREFS

Cf. A005132, A336957, A098550, A165430.
Sequence in context: A113880 A339192 A171884 * A226940 A098141 A175458
Adjacent sequences: A339554 A339555 A339556 * A339558 A339559 A339560


KEYWORD

nonn


AUTHOR

Scott R. Shannon, Dec 08 2020


STATUS

approved



