A215879 Written in base 3, n ends in a(n) consecutive nonzero digits.
0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 4, 4, 0, 4, 4, 0, 1, 1, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 3, 3, 0, 3, 3, 0, 1, 1, 0, 3, 3, 0, 3
Offset: 0
Examples
The numbers 0, 1, 2, 3, 4, 5, 6, 7 are written in base 3 as 0, 1, 2, 10, 11, 12, 20, 21 and thus end in a(0..7) = 0, 1, 1, 0, 2, 2, 0, 2 nonzero digits.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Crossrefs
Programs
-
Haskell
a215879 n = if t == 0 then 0 else a215879 n' + 1 where (n',t) = divMod n 3 -- Reinhard Zumkeller, Dec 28 2012
-
Mathematica
cnzd[n_]:=Module[{idn3=IntegerDigits[n,3],len},len=Length[idn3];Which[ idn3[[len]] == 0,0,Position[idn3,0]=={},len,True,len-Position[idn3,0] [[-1,1]]]]; Array[cnzd,110,0] (* Harvey P. Dale, Jun 07 2016 *)
-
PARI
A215879(n,b=3)=n=divrem(n,b); for(c=0,oo,n[2]||return(c); n=divrem(n[1],b))
-
PARI
a(n)=my(k);while(n%3,n\=3;k++);k \\ Charles R Greathouse IV, Sep 26 2013
-
Python
def A215879(n): c = 0 while (a:=divmod(n,3))[1]: c += 1 n = a[0] return c # Chai Wah Wu, Oct 15 2022
Formula
a(3^(t+1)*k+m) = t for 3^t > m > 3^(t-1).
a(3n) = 0, a(3n+1) = a(3n+2) = a(n)+1. - M. F. Hasler, Aug 26 2012, corrected thanks to a remark from Jianing Song, Aug 23 2022
Comments