login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

a(0) = 0, a(1) = 1, a(2) = -1, a(3) = 2, and for n > 3, a(n) is the least integer (in absolute value) not yet in the sequence sharing a factor with a(n-1); in case of a tie, preference is given to the positive value.
1

%I #12 Oct 23 2024 14:40:34

%S 0,1,-1,2,-2,4,-4,6,3,-3,-6,8,-8,10,5,-5,-10,12,9,-9,-12,14,7,-7,-14,

%T 16,-16,18,15,-15,-18,20,-20,22,11,-11,-22,24,21,-21,-24,26,13,-13,

%U -26,28,-28,30,25,-25,-30,27,-27,33,-33,36,32,-32,34,17,-17,-34

%N a(0) = 0, a(1) = 1, a(2) = -1, a(3) = 2, and for n > 3, a(n) is the least integer (in absolute value) not yet in the sequence sharing a factor with a(n-1); in case of a tie, preference is given to the positive value.

%C This sequence is a variant of the EKG sequence (A064413) allowing negative values; both sequences share similar features.

%C For any pair of prime numbers p and q such that p < q, a multiple of q is always preceded by a multiple of p.

%C For any odd prime number p, the first multiple of p is followed by p, -p and 2*p or -2*p, in that order.

%C All prime numbers appear in the sequence:

%C - by contradiction: if the sequence is p-smooth for some prime number p appearing in the sequence,

%C - there are infinitely many multiples of some prime number q <= p in the sequence,

%C - so all multiples of q will show up, including q*r some some prime number r > p, a contradiction.

%C Hence, the sequence contains infinitely many even numbers, and so all even numbers will show up.

%C For any nonzero integer v, as there are infinitely many even multiples of v in the sequence, and these are all chances for v to be chosen, so v will eventually appear: this sequence is a bijection from the nonnegative integers (N) to the integers (Z).

%C Partials sums are nonnegative (for any n > 0, among the first n terms, a negative term, say -v, will always be cancelled by the corresponding positive term v appearing prior, but some positive term might be present without the corresponding negative term).

%H Rémy Sigrist, <a href="/A377225/b377225.txt">Table of n, a(n) for n = 0..10000</a>

%H Rémy Sigrist, <a href="/A377225/a377225.gp.txt">PARI program</a>

%H <a href="/index/Ed#EKG">Index entries for sequences related to EKG sequence</a>

%F Sum_{k = 0..n} a(k) >= 0 for any n >= 0.

%e The first terms are:

%e n a(n) gcd(a(n-1), a(n))

%e -- ---- -----------------

%e 0 0 N/A

%e 1 1 1

%e 2 -1 1

%e 3 2 1

%e 4 -2 2

%e 5 4 2

%e 6 -4 4

%e 7 6 2

%e 8 3 3

%e 9 -3 3

%e 10 -6 3

%e 11 8 2

%e 12 -8 8

%e 13 10 2

%e 14 5 5

%e 15 -5 5

%e 16 -10 5

%o (PARI) \\ See Links section.

%o (Python)

%o from math import gcd

%o from itertools import count, islice, product

%o def agen(): # generator of terms

%o a, m = [0, 1, -1, 2], 2

%o yield from a

%o an, aset = a[-1], set(a)

%o for n in count(4):

%o an = next(s*k for k in count(m) for s in [1, -1] if s*k not in aset and gcd(k, an) > 1)

%o yield an

%o aset.add(an)

%o while m in aset and -m in aset: m += 1

%o print(list(islice(agen(), 62))) # _Michael S. Branicky_, Oct 21 2024

%Y Cf. A064413.

%K sign

%O 0,4

%A _Rémy Sigrist_, Oct 20 2024