login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A377388
Infinite sequence of integers a(1), a(2), ... such that for any n > 0, a(n) is as small as possible (in absolute value) and the means of consecutive terms are all distinct; in case of a tie, preference is given to the positive value.
3
0, 1, -2, -3, -5, -8, -6, -11, -13, -21, -16, 9, -42, -24, -25, -27, -34, -35, -46, 10, 2, 90, 42, 31, 26, 11, 30, 18, 58, 41, 20, 86, 43, 60, 45, 103, 48, 54, 105, 83, -48, -151, -155, -59, -87, -79, -146, 106, -157, -109, -218, -208, -88, -45, -99, -131, 27
OFFSET
1,3
COMMENTS
This sequence is a variant of A377351 allowing negative values.
All terms are distinct.
LINKS
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
Sequence in context: A262263 A072987 A010075 * A182445 A010074 A355702
KEYWORD
sign
AUTHOR
Rémy Sigrist, Oct 27 2024
STATUS
approved