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.
%I A377091 #169 Apr 13 2025 00:51:34 %S A377091 0,1,2,-2,-1,3,4,5,-4,-3,6,7,8,-8,-7,-6,-5,-9,-10,-11,-12,13,9,10,11, %T A377091 12,-13,-14,-15,-16,-17,-18,18,14,15,16,17,-19,-20,-21,-22,-23,-24,25, %U A377091 21,20,19,23,22,26,27,28,24,-25,-26,-27,-28,-29,-30,-31,-32,32 %N A377091 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; in case of a tie, preference is given to the positive value. %C A377091 Conjecture 1: Every integer (positive or negative) appears in this sequence. %C A377091 Conjecture 2: For n > 16, |a(n)| is within sqrt(n/2) of floor(n/2). See A379071. - _N. J. A. Sloane_, Dec 29 2024 [Corrected by _Paolo Xausa_, Jan 21 2025] %C A377091 Conjecture 3: lim sup ||a(n)| - floor(n/2)|/sqrt(n) = 1/2. (See link.) - _N. J. A. Sloane_ and _Paolo Xausa_, Feb 03 2025 %C A377091 Conjecture 4: After a(n) has been found, the sequence contains all numbers in the range [0,f(n)], where lim sup f(n) = (n-sqrt(n))/2. There is a corresponding conjecture for the negative terms. See A379067. - _N. J. A. Sloane_ and _Paolo Xausa_, Feb 13 2025 %H A377091 N. J. A. Sloane, <a href="/A377091/b377091.txt">Table of n, a(n) for n = 0..20000</a> [First 10000 terms from Rémy Sigrist] %H A377091 M. F. Hasler, <a href="/A377091/a377091_2.html">Interactive spiral graph representation of the first n terms</a>, Jan 18 2025. %H A377091 Kerry Mitchell, <a href="/A377091/a377091_2.jpg">Spiral graph representation of first 31 terms</a> %H A377091 Kerry Mitchell, <a href="/A377091/a377091_3.jpg">Colored spiral graph representation of first 100 terms</a> %H A377091 Chris Scussel, <a href="/A377091/a377091.pdf">Spiral graph representation of 5000 terms</a> %H A377091 Rémy Sigrist, <a href="/A377091/a377091.png">Scatterplot of the first 10000 terms of the partial sums</a> %H A377091 Rémy Sigrist, <a href="/A377091/a377091_1.png">Christmas card based on graph of the partial sums</a> [Rotate graph by 90 degs, add color and decorations] %H A377091 Rémy Sigrist, <a href="/A377091/a377091.gp.txt">PARI program</a> %H A377091 N. J. A. Sloane, <a href="/A377091/a377091.txt">Table of n, a(n) for n = 0..250000</a> %H A377091 N. J. A. Sloane, <a href="/A377091/a377091_1.jpg">Spiral graph representation of first 28 terms</a> [Hand-drawn] %H A377091 Paolo Xausa, <a href="/A377091/a377091_2.png">Scatterplot of ||a(n)| - floor(n/2)| for 0 <= n <= 200000.</a> The orange line is sqrt(n)/2. %e A377091 The initial terms are: %e A377091 n a(n) |a(n)-a(n-1)| %e A377091 -- ---- ------------- %e A377091 0 0 N/A %e A377091 1 1 1^2 %e A377091 2 2 1^2 %e A377091 3 -2 2^2 %e A377091 4 -1 1^2 %e A377091 5 3 2^2 %e A377091 6 4 1^2 %e A377091 7 5 1^2 %e A377091 8 -4 3^2 %e A377091 9 -3 1^2 %e A377091 10 6 3^2 %e A377091 11 7 1^2 %e A377091 12 8 1^2 %e A377091 13 -8 4^2 %e A377091 14 -7 1^2 %p A377091 h := proc(b, a, i) option remember; ifelse(issqr(abs(a[-1] - i)) and not is(i in a), ifelse(b < nops(a) + 1, a, h(b, [op(a), i], 1)), h(b, a, ifelse(i < 0, 1 - i, -i))) end: %p A377091 a_list := length -> h(length, [0], 1): a_list(62); # _Peter Luschny_, Jan 20 2025 %t A377091 A377091list[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[Abs[# - a]]], a = Boole[a < 0] - a]; s[a] = True; a) &, 0,nmax]]; %t A377091 A377091list[100] (* _Paolo Xausa_, Mar 18 2025 *) %o A377091 (PARI) \\ See Links section. %o A377091 (PARI) A377091_upto(n,S=[])={vector(n+1, k, S=setunion(S, [n=if(k>1, k=1; while(setsearch(S,k) || !issquare(abs(n-k)), k=(k<0)-k); k)]); n)} \\ _M. F. Hasler_, Jan 18 2025 %o A377091 (Python) %o A377091 from math import isqrt %o A377091 from itertools import count, islice %o A377091 def cond(n): return isqrt(n)**2 == n %o A377091 def agen(): # generator of terms %o A377091 an, aset, m = 0, {0}, 1 %o A377091 for n in count(0): %o A377091 yield an %o A377091 an = next(s for k in count(m) for s in [k, -k] if s not in aset and cond(abs(an-s))) %o A377091 aset.add(an) %o A377091 while m in aset and -m in aset: m += 1 %o A377091 print(list(islice(agen(), 62))) # _Michael S. Branicky_, Dec 25 2024 %o A377091 (Python) %o A377091 from math import sqrt %o A377091 def a_list(b: int, a: list[int] = [0], i: int = 1) -> list[int]: %o A377091 if sqrt(abs(a[-1] - i)).is_integer() and not (i in a): %o A377091 a += [i] %o A377091 if b < len(a): %o A377091 return a %o A377091 else: %o A377091 return a_list(b, a) %o A377091 else: %o A377091 return a_list(b, a, int(i < 0) - i) %o A377091 print(a_list(40)) # _Peter Luschny_, Jan 20 2025 %o A377091 (Python) %o A377091 class A377091: # A377091(n) gives a(n) %o A377091 terms = [0]; N = 1 # next candidate %o A377091 def __new__(A, n): A.extend(A, n-len(A.terms)+1); return A.terms[n] %o A377091 def extend(A, n): any((k:=A.N) in A.terms and setattr(A, 'N', k:=(k<0)-k) or %o A377091 A.terms.append(next(k for _ in range(9**9) if (abs(A.terms[-1]-k)**.5) %o A377091 .is_integer() and k not in A.terms or not(k:=(k<0)-k))) for _ in range(n)) %o A377091 # _M. F. Hasler_, Feb 08 2025 %o A377091 (JavaScript) %o A377091 A377091 = [0]; A377091.least_unused = 1; %o A377091 function a(n){ %o A377091 for(let i = A377091.length-1; i < n; ++i) { %o A377091 let k = A377091.least_unused; %o A377091 while(!Number.isInteger(Math.sqrt(Math.abs(A377091[i] - k))) %o A377091 || A377091.indexOf(k) > 0) k = (k<0)-k; %o A377091 A377091.push(k); %o A377091 if (k == A377091.least_unused) { %o A377091 do k = (k<0)-k; while ( A377091.indexOf( k ) > 0 ); %o A377091 A377091.least_unused = k; %o A377091 } }; %o A377091 return A377091[n]; %o A377091 } // _M. F. Hasler_, Jan 26 2025 %Y A377091 This sequence is a variant of A277616 allowing negative values. %Y A377091 Cf. A277617, A277618, A377090, A377092. %Y A377091 A large number of sequences have been derived from the present sequence in the hope (so far unfulfilled) of finding a formula or recurrence: see A379057-A379078, A379786-A379798, A379802, A379803, A379804, A379880, A380223, A380224, A380225, A382715-A382718. %Y A377091 First differences are A379061 (certainly the most relevant derived sequence). - _M. F. Hasler_, Feb 08 2025 %Y A377091 "Lexicographically earliest" sequences for which there is a proof that every number that could appear does appear: A064413, A098550, A109812, A121216, A347113, etc. - _N. J. A. Sloane_, Feb 08 2025 %K A377091 sign,look,nice %O A377091 0,3 %A A377091 _Rémy Sigrist_, Oct 16 2024