|
|
A323908
|
|
Reversing binary representation of A004718, Per Nørgård's "infinity sequence".
|
|
4
|
|
|
0, 1, 3, 2, 1, 0, 6, 7, 3, 2, 0, 1, 2, 3, 5, 4, 1, 0, 6, 7, 0, 1, 3, 2, 6, 7, 1, 0, 7, 6, 12, 13, 3, 2, 0, 1, 2, 3, 5, 4, 0, 1, 3, 2, 1, 0, 6, 7, 2, 3, 5, 4, 3, 2, 0, 1, 5, 4, 2, 3, 4, 5, 15, 14, 1, 0, 6, 7, 0, 1, 3, 2, 6, 7, 1, 0, 7, 6, 12, 13, 0, 1, 3, 2, 1, 0, 6, 7, 3, 2, 0, 1, 2, 3, 5, 4, 6, 7, 1, 0, 7, 6, 12, 13, 1, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.
|
|
LINKS
|
|
|
FORMULA
|
|
|
PROG
|
(PARI)
up_to = 65536;
A004718list(up_to) = { my(v=vector(up_to)); v[1]=1; v[2]=-1; for(n=3, up_to, v[n] = if(n%2, 1+v[n>>1], -v[n/2])); (v); }; \\ After code in A004718.
v004718 = A004718list(up_to);
A004718(n) = if(!n, n, v004718[n]);
(Python)
from itertools import groupby
c = 0
for k, g in groupby(bin(n)[2:]):
c = c+len(list(g)) if k == '1' else (-c if len(list(g))&1 else c)
return -c^(-c<<1) if c<=0 else c^(c&~-c)<<1 # Chai Wah Wu, Mar 02 2023
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|