cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A379057 #26 Mar 21 2025 18:00:12
%S A379057 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,
%T A379057 14,-11,-7,9,13,-12,-16,20,16,-20,-24,-15,-19,17,21,25,29,33,24,-25,
%U A379057 -21,-17,-26,-22,-18,18,22,26,-23,-27,-31,-35,-39,-30,34,30,-34
%N 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.
%C A379057 Inspired by A377091 and A277616.
%H A379057 Michael S. Branicky, <a href="/A379057/b379057.txt">Table of n, a(n) for n = 0..10000</a>
%t A379057 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]];
%t A379057 A379057list[100] (* _Paolo Xausa_, Mar 21 2025 *)
%o A379057 (Python)
%o A379057 from math import isqrt
%o A379057 from itertools import count, islice
%o A379057 def cond(n): return n > 1 and isqrt(n)**2 == n
%o A379057 def agen(): # generator of terms
%o A379057     an, aset, m = 0, {0}, 1
%o A379057     for n in count(0):
%o A379057         yield an
%o A379057         an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s)))
%o A379057         aset.add(an)
%o A379057         while m in aset and -m in aset: m += 1
%o A379057 print(list(islice(agen(), 62))) # _Michael S. Branicky_, Dec 25 2024
%Y A379057 Cf. A277616, A377091, A379058 (first differences), A380313 (partial sums).
%K A379057 sign
%O A379057 0,2
%A A379057 _N. J. A. Sloane_, Dec 25 2024
%E A379057 More terms from _Michael S. Branicky_, Dec 25 2024