OFFSET
0,4
COMMENTS
The plot seems to have a fractal pattern.
The graph is similar to the Takagi (or blancmange) curve (which also involves bit counts). See A268289. - Kevin Ryde, Dec 04, 2020
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
MATHEMATICA
Block[{a = {0}}, Do[AppendTo[a, a[[-1]] + Which[#1 > #2, #1, #1 < #2, -#2, True, 0] & @@ DigitCount[i, 2]], {i, 68}]; a] (* Michael De Vlieger, Dec 07 2020 *)
PROG
(Python)
from collections import Counter
a = [0]
for i in range(1, 10000):
counts = Counter(str(bin(i))[2:])
if counts['0'] > counts['1']:
a.append(a[-1] - counts['0'])
elif counts['1'] > counts['0']:
a.append(a[-1] + counts['1'])
else:
a.append(a[-1])
print(a)
(PARI) { for (n=0, 68, if (n==0, v=0, b=if (n, binary(n), [0]); c0=#b-c1=vecsum(b); if (c0>c1, v-=c0, c1>c0, v+=c1)); print1 (v", ")) } \\ Rémy Sigrist, Dec 25 2020
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Gioele Bertoncini, Dec 03 2020
STATUS
approved