login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A380356
a(0) = 0, a(1) = 1, and for any n > 0, if a(n) is at square distance from the least integer (in absolute value) not yet in the sequence and of opposite sign to a(n), say u, then a(n+1) = u, otherwise a(n+1) = a(n) + sign(a(n)).
0
0, 1, 2, 3, -1, -2, -3, -4, -5, 4, 5, 6, 7, 8, 9, 10, -6, -7, -8, -9, -10, -11, -12, -13, -14, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
OFFSET
0,3
COMMENTS
This sequence is a variant of A377091 that, by design, contains every integer (positive or negative).
Positive values appear in increasing order, negative values appear in decreasing order.
LINKS
Rémy Sigrist, PARI program
EXAMPLE
a(0) = 0 and a(1) = 1 by definition.
At this point, the least value (in absolute value) not yet in the sequence and of opposite sign is -1.
a(1) is not at square distance from -1, so a(2) = 1 + sign(1) = 2.
a(2) is not at square distance from -1, so a(3) = 2 + sign(2) = 3.
a(3) is at square distance from -1, so a(4) = -1.
At this point, the least value (in absolute value) not yet in the sequence and of opposite sign is 4.
a(4) is not at square distance from 4, so a(5) = -1 + sign(-1) = -2.
PROG
(PARI) \\ See Links section.
CROSSREFS
See A380357 for a similar sequence.
Cf. A377091.
Sequence in context: A194107 A071797 A338027 * A025481 A124171 A276146
KEYWORD
sign,easy,new
AUTHOR
Rémy Sigrist, Jan 22 2025
STATUS
approved