cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

User: Gioele Bertoncini

Gioele Bertoncini's wiki page.

Gioele Bertoncini has authored 1 sequences.

A339413 a(0) = 0; for n > 0, a(n) = a(n-1) if c0 == c1; a(n) = a(n-1) - c0 if c0 > c1; a(n) = a(n - 1) + c1 if c1 > c0, where c0 and c1 are respectively the number of 0's and 1's in the binary expansion of n.

Original entry on oeis.org

0, 1, 1, 3, 1, 3, 5, 8, 5, 5, 5, 8, 8, 11, 14, 18, 14, 11, 8, 11, 8, 11, 14, 18, 15, 18, 21, 25, 28, 32, 36, 41, 36, 32, 28, 28, 24, 24, 24, 28, 24, 24, 24, 28, 28, 32, 36, 41, 37, 37, 37, 41, 41, 45, 49, 54, 54, 58, 62, 67, 71, 76, 81, 87, 81, 76, 71, 67, 62
Offset: 0

Author

Gioele Bertoncini, Dec 03 2020

Keywords

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

Crossrefs

Programs

  • 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 *)
  • 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
  • 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)