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.

A160093 Number of digits in n, excluding any trailing zeros.

Original entry on oeis.org

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

Views

Author

Anonymous, May 01 2009

Keywords

Examples

			a(1060000) = 3 because discarding the trailing zeros from 1060000 leaves 106, which is a 3-digit number.
		

Crossrefs

Programs

  • Mathematica
    lnzd[n_]:=Module[{spl=Last[Split[IntegerDigits[n]]]},If[!MemberQ[ spl,0], IntegerLength[n], IntegerLength[n]-Length[spl]]]; Array[lnzd,110] (* Harvey P. Dale, Jun 05 2013 *)
    Table[IntegerLength[n] - IntegerExponent[n, 10], {n, 100}] (* Amiram Eldar, Sep 14 2020 *)
  • PARI
    a(n)=if(n==0,1,#digits(n/10^valuation(n,10))) \\ Joerg Arndt, Jan 11 2017
    
  • PARI
    a(n)=logint(n,10)+1-valuation(n,10) \\ Charles R Greathouse IV, Jan 12 2017
  • Python
    def A160093(n):
         return len(str(int(str(n)[::-1]))) # Indranil Ghosh, Jan 11 2017
    

Formula

From Hieronymus Fischer, Jun 08 2012: (Start)
With m = floor(log_10(n)), frac(x) = x-floor(x):
a(n) = 1 + Sum_{j=0..m} ceiling(frac(n/10^j)).
a(n) = 1 - Sum_{j=1..m} (floor(-frac(n/10^j))).
a(n)= A055642(n) + A054899(n-1) - A054899(n).
G.f.: (x/(1-x)) + (1/(1-x))*Sum_{j>0} x^(10^j+1)*(1 - x^(10^j-1))/(1-x^10^j). (End)
a(n) = A055642(A004086(n)). - Indranil Ghosh, Jan 11 2017
a(n) = A055642(A004151(n)). - Amiram Eldar, Sep 14 2020

Extensions

Simpler definition and changed example from Jon E. Schoenfield, Feb 15 2014