login
Number of digits in n, excluding any trailing zeros.
27

%I #38 Sep 14 2020 02:59:57

%S 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,

%T 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,

%U 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

%N Number of digits in n, excluding any trailing zeros.

%H Indranil Ghosh, <a href="/A160093/b160093.txt">Table of n, a(n) for n = 1..10000</a>

%F From _Hieronymus Fischer_, Jun 08 2012: (Start)

%F With m = floor(log_10(n)), frac(x) = x-floor(x):

%F a(n) = 1 + Sum_{j=0..m} ceiling(frac(n/10^j)).

%F a(n) = 1 - Sum_{j=1..m} (floor(-frac(n/10^j))).

%F a(n)= A055642(n) + A054899(n-1) - A054899(n).

%F 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)

%F a(n) = A055642(A004086(n)). - _Indranil Ghosh_, Jan 11 2017

%F a(n) = A055642(A004151(n)). - _Amiram Eldar_, Sep 14 2020

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

%t 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 *)

%t Table[IntegerLength[n] - IntegerExponent[n, 10], {n, 100}] (* _Amiram Eldar_, Sep 14 2020 *)

%o (Python)

%o def A160093(n):

%o return len(str(int(str(n)[::-1]))) # _Indranil Ghosh_, Jan 11 2017

%o (PARI) a(n)=if(n==0,1,#digits(n/10^valuation(n,10))) \\ _Joerg Arndt_, Jan 11 2017

%o (PARI) a(n)=logint(n,10)+1-valuation(n,10) \\ _Charles R Greathouse IV_, Jan 12 2017

%Y Cf. A004151, A054899, A055640, A055641, A055642, A102669, A122840, A122841, A160094, A196563, A196564.

%K base,easy,nonn

%O 1,11

%A Anonymous, May 01 2009

%E Simpler definition and changed example from _Jon E. Schoenfield_, Feb 15 2014