cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A071858 (Number of 1's in binary expansion of n) mod 3.

Original entry on oeis.org

0, 1, 1, 2, 1, 2, 2, 0, 1, 2, 2, 0, 2, 0, 0, 1, 1, 2, 2, 0, 2, 0, 0, 1, 2, 0, 0, 1, 0, 1, 1, 2, 1, 2, 2, 0, 2, 0, 0, 1, 2, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 0, 1, 2, 2, 0, 2, 0, 0, 1, 2, 0, 0, 1, 0, 1, 1, 2, 2, 0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 0, 2, 0, 0, 1, 0, 1, 1, 2, 0
Offset: 0

Views

Author

Benoit Cloitre, Jun 09 2002

Keywords

Comments

This is the generalized Thue-Morse sequence t_3 (Allouche and Shallit, p. 335).
Ternary sequence which is a fixed point of the morphism 0 -> 01, 1 -> 12, 2 -> 20.
Sequence is T^(oo)(0) where T is the operator acting on any word on alphabet {0,1,2} by inserting 1 after 0, 2 after 1 and 0 after 2. For instance T(001)=010112, T(120)=122001. - Benoit Cloitre, Mar 02 2009

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003.

Crossrefs

See A245555 for another version.

Programs

  • Mathematica
    f[n_] := Mod[ Count[ IntegerDigits[n, 2], 1], 3]; Table[ f[n], {n, 0, 104}] (* Or *)
    Nest[ Flatten[ # /. {0 -> {0, 1}, 1 -> {1, 2}, 2 -> {2, 0}}] &, {0}, 7] (* Robert G. Wilson v Mar 03 2005, modified May 17 2014 *)
    Table[Mod[DigitCount[n,2,1],3],{n,0,110}] (* Harvey P. Dale, Jul 01 2015 *)
  • PARI
    for(n=1,200,print1(sum(i=1,length(binary(n)), component(binary(n),i))%3,","))
    
  • PARI
    map(d)=if(d==2,[2,0],if(d==1,[1,2],[0,1]))
    {m=53;v=[];w=[0];while(v!=w,v=w;w=[];for(n=1,min(m,length(v)),w=concat(w,map(v[n]))));for(n=1,2*m,print1(v[n],","))} \\ Klaus Brockhaus, Jun 23 2004

Formula

a(n) = A010872(A000120(n)).
Recurrence: a(2*n) = a(n), a(2*n+1) = (a(n)+1) mod 3.
a(n) = A000695(n) mod 3. - John M. Campbell, Jul 16 2016

Extensions

Edited by Ralf Stephan, Dec 11 2004

A332251 a(n) is the real part of f(n) defined by f(0) = 0 and f(n+1) = f(n) + i^A000120(n) (where i denotes the imaginary unit). Sequence A332252 gives imaginary parts.

Original entry on oeis.org

0, 1, 1, 1, 0, 0, -1, -2, -2, -2, -3, -4, -4, -5, -5, -5, -4, -4, -5, -6, -6, -7, -7, -7, -6, -7, -7, -7, -6, -6, -5, -4, -4, -4, -5, -6, -6, -7, -7, -7, -6, -7, -7, -7, -6, -6, -5, -4, -4, -5, -5, -5, -4, -4, -3, -2, -2, -2, -1, 0, 0, 1, 1, 1, 0, 0, -1, -2
Offset: 0

Views

Author

Rémy Sigrist, Feb 08 2020

Keywords

Comments

The representation of {f(n)} corresponds to a Lévy C Curve.

Examples

			The first terms, alongside f(n) and A000120(n), are:
  n   a(n)  f(n)    A000120(n)
  --  ----  ------  ----------
   0     0       0           0
   1     1       1           1
   2     1     1+i           1
   3     1   1+2*i           2
   4     0     2*i           1
   5     0     3*i           2
   6    -1  -1+3*i           2
   7    -2  -2+3*i           3
   8    -2  -2+2*i           1
   9    -2  -2+3*i           2
  10    -3  -3+3*i           2
  11    -4  -4+3*i           3
  12    -4  -4+2*i           2
  13    -5  -5+2*i           3
  14    -5    -5+i           3
  15    -5      -5           4
  16    -4      -4           1
From _Kevin Ryde_, Sep 24 2020: (Start)
  n    =   2^9 +   2^8 +     2^5 +     2^2 +     2^1 = 806
  f(n) = 1*b^9 + i*b^8 + i^2*b^5 + i^3*b^2 + i^4*b^1 = 23 + 37*i
so a(806) = 23 and A332252(806) = 37.
(End)
		

Crossrefs

Cf. A332252 (imaginary part), A000120 (segment direction), A179868 (segment direction mod 4).
Cf. A332383 (dragon curve).

Programs

  • PARI
    { z=0; for (n=0, 67, print1 (real(z) ", "); z += I^hammingweight(n)) }
    
  • PARI
    a(n) = my(v=binary(n),s=1); for(i=2,#v, if(v[i],v[i]=(s*=I))); real(subst(Pol(v),'x,1+I)); \\ Kevin Ryde, Sep 24 2020

Formula

For any k >= 0:
- a(2^(4*k)) = (-4)^k,
- a(2^(4*k+1)) = (-4)^k,
- a(2^(4*k+2)) = 0,
- a(2^(4*k+3)) = -2*(-4)^k.
From Kevin Ryde, Sep 24 2020: (Start)
With complex b = 1+i,
f(2*n) = b*f(n) and f(2*n+1) = f(2*n) + i^A000120(2*n), expand and step.
f(2^k + r) = b^k + i*f(r), for 0 <= r < 2^k, replication.
f(n) = Sum_{j=0..t} i^j*b^k[j] where binary n = 2^k[0] + ... + 2^k[t] with descending powers k[0] > ... > k[t] >= 0, so change binary to base b with rotating coefficient i^0, i^1, i^2, ... at each 1-bit.
(End)
Showing 1-2 of 2 results.