A081604 Number of digits in ternary representation of n.
1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
Offset: 0
Examples
a(8) = 2 because 8 = 22_3, having 2 digits. a(9) = 3 because 9 = 100_3, having 3 digits.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Eric Weisstein's World of Mathematics, Ternary.
Crossrefs
Programs
-
Haskell
a081604 n = if n < 3 then 1 else a081604 (div n 3) + 1 -- Reinhard Zumkeller, Sep 05 2014, Feb 21 2013
-
Maple
A081604 := proc(n) max(1,1+ilog[3](n)) ; end proc: # R. J. Mathar, Jul 12 2016
-
Mathematica
Table[Length[IntegerDigits[n, 3]], {n, 0, 99}] (* Alonso del Arte, Dec 30 2012 *) Join[{1},IntegerLength[Range[120],3]] (* Harvey P. Dale, Apr 07 2019 *)
Formula
a(n) = A062153(n) + 1 for n >= 1.
From Reinhard Zumkeller, Oct 19 2007: (Start)
0 <= A134021(n) - a(n) <= 1;
a(n+1) = -Sum_{k=1..n} mu(3*k)*floor(n/k). - Benoit Cloitre, Oct 21 2009
a(n) = floor(log_3(n)) + 1. - Can Atilgan and Murat Erşen Berberler, Dec 05 2012
a(n) = if n < 3 then 1 else a(floor(n/3)) + 1. - Reinhard Zumkeller, Sep 05 2014
G.f.: 1 + (1/(1 - x))*Sum_{k>=0} x^(3^k). - Ilya Gutkovskiy, Jan 08 2017
Comments