|
|
A255817
|
|
Parity of A000788, which is the total number of ones in 0..n in binary.
|
|
1
|
|
|
0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0
|
|
COMMENTS
|
a(n) is also the parity of A115384.
a(n) is also the base 2 version of the process described in A256379.
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
a(3) = 0, because there are an even number of ones in [0,1,10,11].
a(5) = 1, because there are an odd number of ones in [0,1,10,11,100,101].
|
|
MATHEMATICA
|
Boole @* OddQ /@ Accumulate@ Array[DigitCount[#, 2, 1] &, 120, 0] (* Michael De Vlieger, Mar 29 2023 *)
|
|
PROG
|
(Sage)
A = [0]
for n in range(1, N+1):
n2 = bin(n)[2:]
A.append(mod(A[-1]+sum([int(n2[j]) for j in range(len(n2))]), 2))
return A
(Python)
def A255817(n): return ((n>>1)&1)^(n&1|((n+1).bit_count()&1^1)) # Chai Wah Wu, Mar 01 2023
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|