A065882 Ultimate modulo 4: right-hand nonzero digit of n when written in base 4.
1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 2, 1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 3, 1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 3, 1, 2, 3, 2, 1, 2, 3, 1, 1, 2, 3, 2, 1
Offset: 1
Examples
a(7)=3 and a(112)=3, since 7 is written in base 4 as 13 and 112 as 1300.
References
- M. Baake and U. Grimm, Aperiodic Order Vol. 1, Cambridge University Press, 2013, page 205.
Links
- Harry J. Smith, Table of n, a(n) for n = 1..1000
- D. Frettlöh, Nichtperiodische Pflasterungen mit ganzzahligem Inflationsfaktor, Dissertation, Universität Dortmund, 2002.
- Index entries for sequences related to final digits of numbers
- Index entries for sequences that are fixed points of mappings
Crossrefs
Programs
-
Maple
f:= proc(n) local x:=n; while x mod 4 = 0 do x:= x/4 od: x mod 4; end proc; map(f, [$1..100]); # Robert Israel, Jan 05 2016
-
Mathematica
Nest[ Flatten[ # /. {1 -> {1, 2, 3, 1}, 2 -> {1, 2, 3, 2}, 3 -> {1, 2, 3, 3}}] &, {1}, 4] (* Robert G. Wilson v, May 07 2005 *) b[n_] := CoefficientList[Series[ With[{f0 = (x + 2 x^2 + 3 x^3)/(1 - x^4)}, Nest[ (# /. x -> x^4) + f0 &, f0, Ceiling[Log[4, n/3]]]], {x, 0, n}], x][[2 ;; -1]]; b[100](* Bradley Klee, Sep 12 2015 *) Table[Mod[n/4^IntegerExponent[n, 4], 4], {n, 1, 120}] (* Clark Kimberling, Oct 19 2016 *)
-
PARI
a(n) = (n/4^valuation(n,4))%4; \\ Joerg Arndt, Sep 13 2015
-
Python
def A065882(n): return (n>>((~n & n-1).bit_length()&-2))&3 # Chai Wah Wu, Aug 21 2023
Formula
If n mod 4 = 0 then a(n) = a(n/4), otherwise a(n) = n mod 4. a(n) = A065883(n) mod 4.
Fixed point of the morphism: 1 ->1231, 2 ->1232, 3 ->1233, starting from a(1) = 1. Sequence read mod 2 gives A035263. a(n) = A007913(n) mod 4. - Philippe Deléham, Mar 28 2004
G.f. g(x) satisfies g(x) = g(x^4) + (x + 2 x^2 + 3 x^3)/(1 - x^4). - Bradley Klee, Sep 12 2015
Comments