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.
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
Keywords
Examples
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
Links
- Rémy Sigrist, Table of n, a(n) for n = 1..10000
- Rémy Sigrist, C++ program
Programs
-
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
Comments