login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A377091
a(0) = 0, and for any n > 0, a(n) is the least integer (in absolute value) not yet in the sequence such that the absolute difference of a(n-1) and a(n) is a square; in case of a tie, preference is given to the positive value.
3
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, 12, -13, -14, -15, -16, -17, -18, 18, 14, 15, 16, 17, -19, -20, -21, -22, -23, -24, 25, 21, 20, 19, 23, 22, 26, 27, 28, 24, -25, -26, -27, -28, -29, -30, -31, -32, 32
OFFSET
0,3
COMMENTS
This sequence is a variant of A277616 allowing negative values.
Will every integer appear in the sequence?
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..20000 [First 10000 terms from Rémy Sigrist]
Rémy Sigrist, PARI program
EXAMPLE
The first terms are:
n a(n) |a(n)-a(n-1)|
-- ---- -------------
0 0 N/A
1 1 1^2
2 2 1^2
3 -2 2^2
4 -1 1^2
5 3 2^2
6 4 1^2
7 5 1^2
8 -4 3^2
9 -3 1^2
10 6 3^2
11 7 1^2
12 8 1^2
13 -8 4^2
14 -7 1^2
PROG
(PARI) \\ See Links section.
(Python)
from math import isqrt
from itertools import count, islice
def cond(n): return 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
KEYWORD
sign,look,changed
AUTHOR
Rémy Sigrist, Oct 16 2024
STATUS
approved