OFFSET
1,3
COMMENTS
This sequence is a variant of A377351 allowing negative values.
All terms are distinct.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10000
Rémy Sigrist, C++ program
EXAMPLE
The first terms, alongside the means of consecutive terms ending with a(n), are:
n a(n) Corresponding means
- ---- -----------------------------------------
1 0 0
2 1 1/2, 1
3 -2 -1/3, -1/2, -2
4 -3 -1, -4/3, -5/2, -3
5 -5 -9/5, -9/4, -10/3, -4, -5
6 -8 -17/6, -17/5, -9/2, -16/3, -13/2, -8
7 -6 -23/7, -23/6, -24/5, -11/2, -19/3, -7, -6
PROG
(C++) // See Links section.
(Python)
from fractions import Fraction
from itertools import count, islice
def A377388gen(): # generator of terms
alst, means_seen = [0], {0}
while True:
yield alst[-1]
for i in count(1):
failed = True
for k in [i, -i]:
if k in means_seen: continue
mk, failed, sk = {k}, False, k
for j in range(1, len(alst)+1):
sk += alst[-j]
m = Fraction(sk, j+1)
if m in means_seen or m in mk: failed = True; break
mk.add(m)
if not failed:
means_seen |= mk
alst.append(k)
break
if not failed: break
print(list(islice(A377388gen(), 60))) # Michael S. Branicky, Oct 27 2024, Oct 28 2024
CROSSREFS
KEYWORD
sign
AUTHOR
Rémy Sigrist, Oct 27 2024
STATUS
approved