A060236 If n mod 3 = 0 then a(n) = a(n/3), otherwise a(n) = n mod 3.
1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2
Offset: 1
Examples
a(10)=1 since 10=3^0*10 and 10 mod 3=1; a(72)=2 since 24=3^3*8 and 8 mod 3=2.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..1000
- Jean Berstel and J. Karhumaki, Combinatorics on words - a tutorial, Bull. EATCS, #79 (2003), pp. 178-228.
- Index entries for sequences related to final digits of numbers
- Index entries for sequences that are fixed points of mappings
Crossrefs
Programs
-
Haskell
following Franklin T. Adams-Watters's comment. a060236 = head . dropWhile (== 0) . a030341_row -- Reinhard Zumkeller, Mar 13 2015
-
Magma
[(Floor(n/3^Valuation(n, 3)) mod 3): n in [1..120]]; // G. C. Greubel, Nov 05 2024
-
Mathematica
Nest[ Flatten[ # /. {1 -> {1, 2, 1}, 2 -> {1, 2, 2}}] &, {1}, 5] (* Robert G. Wilson v, Mar 04 2005 *) Table[Mod[n/3^IntegerExponent[n, 3], 3], {n, 1, 120}] (* Clark Kimberling, Oct 19 2016 *) lnzd[m_]:=Module[{s=Split[m]},If[FreeQ[Last[s],0],s[[-1,1]],s[[-2,1]]]]; lnzd/@Table[IntegerDigits[n,3],{n,120}] (* Harvey P. Dale, Oct 19 2018 *)
-
PARI
a(n)=if(n<1, 0, n/3^valuation(n,3)%3) /* Michael Somos, Nov 10 2005 */
-
SageMath
[n/3^valuation(n, 3)%3 for n in range(1,121)] # G. C. Greubel, Nov 05 2024
Formula
a(3*n) = a(n), a(3*n + 1) = 1, a(3*n + 2) = 2. - Michael Somos, Jul 29 2009
a(n) = 1 + A080846(n). - Joerg Arndt, Jan 21 2013
Comments