A383442 a(0) = 0; thereafter a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference between a(n-1) and a(n) is a triangular number; in case of a tie, preference is given to the positive value.
0, 1, 2, -1, -2, -3, 3, 4, 5, -5, -4, 6, 7, 8, -7, -6, 9, 10, 11, -10, -9, -8, -11, -12, -13, -14, 14, 13, 12, 15, 16, 17, 18, -18, -15, -16, -17, 19, 20, 21, 22, 23, -22, -19, -20, -21, 24, 25, 26, 27, 28, -27, -24, -23, -26, -25, -28, -29, -30, -31, -32, -33, 33, 30, 29, 32, 31, 34, 35, 36, 37, 38, 39, -39, -36, -35, -34, -37, -38, 40
Offset: 0
Keywords
Links
- Michael S. Branicky, Table of n, a(n) for n = 0..20000
Programs
-
Mathematica
A383442list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || !IntegerQ[Sqrt[8*Abs[# - a]+1]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0, nmax]]; A383442list[100] (* Paolo Xausa, May 05 2025 *)
-
Python
from math import isqrt from itertools import count, islice def cond(n): return isqrt(m:=8*n+1)**2 == m def agen(): # generator of terms an, aset, m = 0, {0}, 1 for n in count(0): yield an an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s))) aset.add(an) while m in aset and -m in aset: m += 1 print(list(islice(agen(), 80))) # Michael S. Branicky, May 03 2025
Comments