OFFSET
0,4
COMMENTS
This sequence is a variant of A377091, based on powers of 2 instead of squares.
Every integer (positive or negative) appears in this sequence.
Indeed, the sequence has the following structure:
- a transient block T corresponding to the initial terms a(0) to a(8),
- then, for k = 2, 3, etc., blocks B(k) with the following properties:
- the initial blocks T, B(2), ..., B(k-1) form a permutation of -2^k..2^k and end with the value -2^k + 1,
- the block B(k) starts with the positive values 2^k+1, 2^k+2, ..., 2^(k+1),
- then continues with the negative values -2^(k+1), -2^(k+1) + 2^(k-1), -2^(k+1) + 2^(k-1) + 2^(k-2), ..., -2^(k+1) + 2^(k-1) + 2^(k-2) + ... + 2^0,
- then continues with the missing negative values down to -2^(k+1) + 1 with steps of -1 or -2.
As a consequence, nonnegative values appear in their natural order.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, PARI program
EXAMPLE
The first terms are:
n a(n) |a(n)-a(n-1)|
-- ---- -------------
0 0 N/A
1 1 2^0
2 -1 2^1
3 -2 2^0
4 2 2^2
5 3 2^0
6 4 2^0
7 -4 2^3
8 -3 2^0
9 5 2^3
10 6 2^0
11 7 2^0
12 8 2^0
13 -8 2^4
14 -6 2^1
MATHEMATICA
A379719list[nmax_] := Module[{s, a, u = 1}, s[_] := False; s[0] = True; NestList[(While[s[u] && s[-u], u++]; a = u; While[s[a] || (BitAnd[#, #-1] & [Abs[# - a]]) > 0, a = Boole[a < 0] - a]; s[a] = True; a) &, 0, nmax]];
A379719list[100] (* Paolo Xausa, Feb 18 2026 *)
PROG
(PARI) \\ See Links section.
CROSSREFS
KEYWORD
sign
AUTHOR
Rémy Sigrist, Dec 31 2024
STATUS
approved
