cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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
Offset: 0

Views

Author

Scott R. Shannon, Dec 08 2020

Keywords

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(n-1) - n can occur only if gcd(a(n-1),n) > 1 or gcd(a(n-2),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 occurred after 100 million terms.

Examples

			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.
		

Crossrefs

Programs

  • 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 *)