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.

A339601 Starting from x_0 = n, iterate by dividing with 3 (discarding any remainder), until zero is reached: x_1 = floor(x_0/3), x_2 = floor(x_1/3), etc. Then a(n) = Sum_{i=0..} (x_i AND 2^i), where AND is bitwise-and.

Original entry on oeis.org

0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7, 6, 7, 6, 7, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3
Offset: 0

Views

Author

Antti Karttunen, Dec 09 2020

Keywords

Crossrefs

Cf. also A332497.

Programs

  • Mathematica
    Array[Total@ MapIndexed[BitAnd[2^First[#2 - 1], #1] &, NestWhileList[Floor[#/3] &, #, # > 0 &]] &, 106, 0] (* Michael De Vlieger, Dec 10 2020 *)
  • PARI
    A339601(n) = { my(i=0, s=0); while(n, s += bitand(2^i,n); i++; n \= 3); (s); };
    
  • PARI
    A339601(n) = { my(m=1, s=0); while(n>=m, s += bitand(m,n); m <<= 1; n \= 3); (s); };