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, Scatterplot of the first 10000 terms of the partial sums
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
AUTHOR
Rémy Sigrist, Oct 16 2024
STATUS
approved