login
A379057
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 square > 1; in case of a tie, preference is given to the positive value.
4
0, 4, -5, -1, 3, -6, -2, 2, 6, -3, 1, 5, -4, -8, 8, 12, -13, -9, 7, 11, -14, -10, 15, 19, 10, 14, -11, -7, 9, 13, -12, -16, 20, 16, -20, -24, -15, -19, 17, 21, 25, 29, 33, 24, -25, -21, -17, -26, -22, -18, 18, 22, 26, -23, -27, -31, -35, -39, -30, 34, 30, -34
OFFSET
0,2
COMMENTS
Inspired by A377091 and A277616.
LINKS
MATHEMATICA
A379057list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || Abs[# - a] <= 1 || !IntegerQ[Sqrt[Abs[# - a]]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0, nmax]];
A379057list[100] (* Paolo Xausa, Mar 21 2025 *)
PROG
(Python)
from math import isqrt
from itertools import count, islice
def cond(n): return n > 1 and isqrt(n)**2 == n
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(), 62))) # Michael S. Branicky, Dec 25 2024
CROSSREFS
Cf. A277616, A377091, A379058 (first differences), A380313 (partial sums).
Sequence in context: A378614 A378456 A195853 * A070769 A021693 A188944
KEYWORD
sign
AUTHOR
N. J. A. Sloane, Dec 25 2024
EXTENSIONS
More terms from Michael S. Branicky, Dec 25 2024
STATUS
approved