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.

A316863 Number of times 2 appears in the decimal expansion of n.

Original entry on oeis.org

0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
Offset: 0

Views

Author

Robert G. Wilson v, Jul 15 2018

Keywords

Examples

			a(0) = 0 since the decimal representation of 0 does not contain the digit 2.
a(2) = 1 since 2 appears once in the decimal expansion of 2.
a(22) = 2 since 2 appears twice in the decimal expansion of 22.
		

Crossrefs

Programs

  • Maple
    f:= n -> numboccur(2,convert(n,base,10)):
    map(f, [$0..200]); # Robert Israel, Apr 21 2020
  • Mathematica
    Array[ DigitCount[#, 10, 2] &, 105, 0]
  • PARI
    a(n) = #select(x->x==2, digits(n)); \\ Michel Marcus, Jul 20 2018

Formula

G.f.: (1-x)^(-1)*Sum_{k>=0} (x^(2*10^k)-x^(3*10^k))/(1-x^(10^(k+1))). - Robert Israel, Apr 21 2020