login
Number of zeros in base-3 expansion of n.
40

%I #32 Jul 04 2021 12:35:17

%S 1,0,0,1,0,0,1,0,0,2,1,1,1,0,0,1,0,0,2,1,1,1,0,0,1,0,0,3,2,2,2,1,1,2,

%T 1,1,2,1,1,1,0,0,1,0,0,2,1,1,1,0,0,1,0,0,3,2,2,2,1,1,2,1,1,2,1,1,1,0,

%U 0,1,0,0,2,1,1,1,0,0,1,0,0,4,3,3,3,2,2,3,2,2,3,2,2,2,1,1,2,1,1,3,2,2,2,1,1,2

%N Number of zeros in base-3 expansion of n.

%H Reinhard Zumkeller, <a href="/A077267/b077267.txt">Table of n, a(n) for n = 0..10000</a>

%H F. T. Adams-Watters, F. Ruskey, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL12/Ruskey2/ruskey14.html">Generating Functions for the Digital Sum and Other Digit Counting Sequences</a>, JIS 12 (2009) 09.5.6

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Ternary.html">Ternary</a>.

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Ternary_numeral_system">Ternary numeral system</a>

%F a(1)=a(2)=0; a(3n)=a(n)+1; a(3n+1)=a(3n+2)=a(n). a(3^n-2)=a(3^n-1)=0; a(3^n)=n. a(n)=A077266(n, 3).

%F a(n) + A062756(n) + A081603(n) = A081604(n). - _Reinhard Zumkeller_, Mar 23 2003

%F G.f.: (Sum_{k>=0} x^(3^(k+1))/(1 + x^(3^k) + x^(2*3^k)))/(1-x). - _Franklin T. Adams-Watters_, Nov 03 2005

%F a(n) = A079978(n) if n < 3, A079978(n) + a(floor(n/3)) otherwise. - _Reinhard Zumkeller_, Feb 21 2013

%e a(8)=0 since 8 written in base 3 is 22 with 0 zeros;

%e a(9)=2 since 9 written in base 3 is 100 with 2 zeros;

%e a(10)=1 since 10 written in base 3 is 101 with 1 zero.

%t Table[Count[IntegerDigits[n,3],0],{n,0,6!}] (* _Vladimir Joseph Stephan Orlovsky_, Jul 25 2009 *)

%t DigitCount[Range[0,110],3,0] (* _Harvey P. Dale_, Jul 04 2021 *)

%o (Haskell)

%o a077267 n = a079978 n + if n < 3 then 0 else a077267 (n `div` 3)

%o -- _Reinhard Zumkeller_, Feb 21 2013

%Y Cf. A023416, A077266, A062756, A081603.

%Y Cf. A007089, A081605, A032924, A081607, A081608, A077267, A134023. - _Reinhard Zumkeller_, Mar 23 2003

%K base,nonn

%O 0,10

%A _Henry Bottomley_, Nov 01 2002

%E a(0)=1 added, offset changed to 0 and b-file adjusted by _Reinhard Zumkeller_, Feb 21 2013

%E Wrong formula deleted by _Reinhard Zumkeller_, Feb 21 2013