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.

A122587 Leading digit of n in base 4.

Original entry on oeis.org

1, 2, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 1

Views

Author

Peter C. Heinig (algorithms(AT)gmx.de), Oct 20 2006

Keywords

Comments

Digits 1, 2 and 3 appear cyclically and each time in runs whose lengths are the powers of 4.

Examples

			a(1) = 1/(4^0) = 1.
		

Programs

  • Maple
    seq( evalf(floor(n/ (4^floor(log[4](n))))), n=1..500);
  • Mathematica
    Table[First[IntegerDigits[n, 4]], {n, 100}] (* Alonso del Arte, Sep 30 2011 *)
  • Python
    def A122587(n): return int(bin(n)[2:3+(n.bit_length()&1^1)],2) # Chai Wah Wu, Jan 30 2023

Formula

a(n) = floor(n/(4^floor(log[4](n)))).