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-7 of 7 results.

A062756 Number of 1's in ternary (base-3) expansion of n.

Original entry on oeis.org

0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 1, 2, 3, 2
Offset: 0

Views

Author

Ahmed Fares (ahmedfares(AT)my-deja.com), Jul 16 2001

Keywords

Comments

Fixed point of the morphism: 0 ->010; 1 ->121; 2 ->232; ...; n -> n(n+1)n, starting from a(0)=0. - Philippe Deléham, Oct 25 2011

Crossrefs

Cf. A080846, A343785 (first differences).
Cf. A081606 (indices of !=0).
Indices of terms 0..6: A005823, A023692, A023693, A023694, A023695, A023696, A023697.
Numbers of: A077267 (0's), A081603 (2's), A160384 (1's+2's).
Other bases: A000120, A160381, A268643.

Programs

  • Haskell
    a062756 0 = 0
    a062756 n = a062756 n' + m `mod` 2 where (n',m) = divMod n 3
    -- Reinhard Zumkeller, Feb 21 2013
    
  • Mathematica
    Table[Count[IntegerDigits[i, 3], 1], {i, 0, 200}]
    Nest[Join[#, # + 1, #] &, {0}, 5] (* IWABUCHI Yu(u)ki, Sep 08 2012 *)
  • PARI
    a(n)=if(n<1,0,a(n\3)+(n%3)%2) \\ Paul D. Hanna, Feb 24 2006
    
  • PARI
    a(n)=hammingweight(digits(n,3)%2); \\ Ruud H.G. van Tol, Dec 10 2023
    
  • Python
    from sympy.ntheory import digits
    def A062756(n): return digits(n,3)[1:].count(1) # Chai Wah Wu, Dec 23 2022

Formula

a(0) = 0, a(3n) = a(n), a(3n+1) = a(n)+1, a(3n+2) = a(n). - Vladeta Jovovic, Jul 18 2001
G.f.: (Sum_{k>=0} x^(3^k)/(1+x^(3^k)+x^(2*3^k)))/(1-x). In general, the generating function for the number of digits equal to d in the base b representation of n (0 < d < b) is (Sum_{k>=0} x^(d*b^k)/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x). - Franklin T. Adams-Watters, Nov 03 2005 [For d=0, use the above formula with d=b: (Sum_{k>=0} x^(b^(k+1))/(Sum_{i=0..b-1} x^(i*b^k)))/(1-x), adding 1 if you consider the representation of 0 to have one zero digit.]
a(n) = a(floor(n/3)) + (n mod 3) mod 2. - Paul D. Hanna, Feb 24 2006

Extensions

More terms from Vladeta Jovovic, Jul 18 2001

A292371 A binary encoding of 1-digits in the base-4 representation of n.

Original entry on oeis.org

0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 4, 5, 4, 4, 6, 7, 6, 6, 4, 5, 4, 4, 4, 5, 4, 4, 0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2, 3, 2, 2, 0, 1, 0, 0, 0, 1, 0, 0, 8, 9, 8, 8, 10, 11, 10, 10, 8, 9, 8, 8, 8, 9, 8, 8, 12, 13, 12, 12, 14, 15, 14, 14, 12, 13, 12, 12, 12, 13, 12, 12, 8, 9, 8, 8, 10, 11, 10, 10, 8, 9, 8, 8, 8, 9, 8, 8, 8
Offset: 0

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			   n      a(n)     base-4(n)  binary(a(n))
                  A007090(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        1          1           1
   2        0          2           0
   3        0          3           0
   4        2         10          10
   5        3         11          11
   6        2         12          10
   7        2         13          10
   8        0         20           0
   9        1         21           1
  10        0         22           0
  11        0         23           0
  12        0         30           0
  13        1         31           1
  14        0         32           0
  15        0         33           0
  16        4        100         100
  17        5        101         101
  18        4        102         100
		

Crossrefs

Cf. A289813 (analogous sequence for base 3).

Programs

  • Mathematica
    Table[FromDigits[IntegerDigits[n, 4] /. k_ /; IntegerQ@ k :> If[k == 1, 1, 0], 2], {n, 0, 112}] (* Michael De Vlieger, Sep 21 2017 *)
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n):
        k=digits(n, 4)[1:]
        return 0 if n==0 else int("".join('1' if i==1 else '0' for i in k), 2)
    print([a(n) for n in range(116)]) # Indranil Ghosh, Sep 21 2017
    
  • Python
    def A292371(n): return int(bin(n&~(n>>1))[:1:-2][::-1],2) # Chai Wah Wu, Jun 30 2022

Formula

a(n) = A059905(A292272(n)) = A059905(n AND A003188(n)), where AND is bitwise-AND (A004198).
For all n >= 0, A000120(a(n)) = A160381(n).

A160383 Number of 3's in base-4 representation of n.

Original entry on oeis.org

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

Views

Author

Frank Ruskey, Jun 05 2009

Keywords

Crossrefs

Cf. A007090 (base 4), A160380 (0's), A160381 (1's), A160382 (2's).
Cf. A283316 (mod 2).

Programs

  • PARI
    a(n) = #select(x->(x==3), digits(n, 4)); \\ Michel Marcus, Mar 24 2020

Formula

Recurrence relation: a(0) = 0, a(4m+3) = 1+a(m), a(4m) = a(4m+1) = a(4m+2) = a(m).
G.f.: (1/(1-z))*Sum_{m>=0} (z^(3*4^m)*(1 - z^(4^m))/(1 - z^(4^(m+1)))).
Morphism: 0, j -> j,j,j,j+1; e.g., 0 -> 0001 -> 0001000100011112 -> ...

A039005 Numbers whose base-4 representation has the same number of 1's and 3's.

Original entry on oeis.org

0, 2, 7, 8, 10, 13, 19, 27, 28, 30, 32, 34, 39, 40, 42, 45, 49, 52, 54, 57, 67, 75, 76, 78, 95, 99, 107, 108, 110, 112, 114, 119, 120, 122, 125, 128, 130, 135, 136, 138, 141, 147, 155, 156, 158, 160, 162, 167, 168, 170, 173, 177, 180, 182, 185, 193, 196, 198
Offset: 1

Views

Author

Keywords

Crossrefs

Cf. A004171 (subsequence).

A329101 Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, the number of 1's in the base 4 expansion of n equals the number of 2's in the base 4 expansion of a(n).

Original entry on oeis.org

0, 2, 1, 3, 6, 10, 8, 9, 4, 11, 5, 7, 12, 14, 13, 15, 18, 26, 22, 24, 34, 42, 38, 40, 25, 41, 27, 30, 32, 43, 33, 35, 16, 36, 17, 19, 37, 46, 39, 44, 20, 45, 21, 23, 28, 47, 29, 31, 48, 50, 49, 51, 54, 58, 56, 57, 52, 59, 53, 55, 60, 62, 61, 63, 66, 74, 70, 72
Offset: 0

Views

Author

Rémy Sigrist, Nov 07 2019

Keywords

Comments

This sequence is a permutation of the nonnegative integers with inverse A329180.
Apparently, fixed points correspond to A001196.
The sequence has fractal features; for any k >= 0, the set of points { (n, a(n)), n = 0..4^k-1 } is symmetrical relative to the line of equation y + x = 4^k - 1 (see scatterplots in Links section).

Examples

			The first terms, alongside the base 4 representations of n and of a(n), are:
  n   a(n)  qua(n)  qua(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     2       1          2
   2     1       2          1
   3     3       3          3
   4     6      10         12
   5    10      11         22
   6     8      12         20
   7     9      13         21
   8     4      20         10
   9    11      21         23
  10     5      22         11
  11     7      23         13
  12    12      30         30
  13    14      31         32
  14    13      32         31
  15    15      33         33
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

A160381(n) = A160382(a(n)).

A335380 a(n) is the X-coordinate of the n-th point of the Kochawave curve; sequence A335381 gives Y-coordinates.

Original entry on oeis.org

0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 9, 12, 12, 13, 16, 14, 15, 16, 16, 17, 18, 18, 19, 18, 18, 19, 22, 20, 21, 20, 18, 19, 18, 18, 19, 18, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24, 25, 24, 24, 25, 26, 26, 27, 28, 28, 29, 30, 30
Offset: 0

Views

Author

Rémy Sigrist, Jun 04 2020

Keywords

Comments

Coordinates are given on a hexagonal lattice with X-axis and Y-axis as follows:
Y
/
/
0 ---- X
The Kochawave curve is a variant of the Koch curve that can be built by successively applying the following substitution to an initial vector (1, 0):
.+ C
.../
... /
... /
+------>+. +------>+
A B D E
- the points A, B, D and E are aligned and equally spaced,
- the points D, C and E form an equilateral triangle
(for the Koch curve, the points B, C and D form an equilateral triangle).
The distance between two consecutive points is related to A160381:
- for any n >= 0, let z(n) = a(n) + A335381(n) * exp(i*Pi/3) (where i denotes the imaginary unit),
- the square of the distance from z(n) to z(n+1) is 3^A160381(n).

Examples

			The Kochawave curve starts (on a hexagonal lattice) as follows:
    .       .       .       .       .       .       +       .       .       .
                                                   /|6
                                                  / |
                                                 /  |
        .       .       .       .       .       .   |   .      .+       .       .
                                               /    |       .../ 8
                                              /     |    ...  /
                                             /      | ...    /
    .       .       .       .       .       .       +.      +       .       .
                                           /         7      |9
                                          /                 |
                                         /                  |
        .       .      .+       .      .+       .       +11 |   .      .+       .
                    .../ 2          ...  5             / \  |       .../ 14
                 ...  /          ...                  /   \ |    ...  /
              ...    /        ...                    /     \| ...    /
    +-------+.      +-------+.      .       .       +-------+.      +-------+
     0       1       3       4                       12   13 10      15      16
- hence a(8) = a(9) = a(11) = a(12) = 6.
		

Crossrefs

Programs

  • PARI
    See Links section.

Formula

a(4^k) = 3^k for any k >= 0.

A374646 Paradiddle version of Thue-Morse sequence.

Original entry on oeis.org

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

Views

Author

Robert P. P. McKone, Jul 15 2024

Keywords

Comments

A paradiddle is a basic drum pattern, either "left left right left" or "right right left right". We can take left, right to be either 0, 1 or 1, 0.
Limiting word of the morphism with maps 0 |--> 0100, 1 |--> 1011 and axiom 1011. - Joerg Arndt, Jul 15 2024

Examples

			k = 0: Sequence starts at its simplest form;
1.
-----------------------------------------------
k = 1: The 1 of the initial sequence expands following the morphism rules, where 1 -> {1, 0, 1, 1} and 0 -> {0, 1, 0, 0}, resulting in;
1, 0, 1, 1.
-----------------------------------------------
k = 2: Each element of the initial sequence expands following the morphism rules, where 1 -> {1, 0, 1, 1} and 0 -> {0, 1, 0, 0};
1, 0, 1, 1,
0, 1, 0, 0,
1, 0, 1, 1,
1, 0, 1, 1.
-----------------------------------------------
k = 3: The expansion is applied recursively, giving:
1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1,
0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0,
1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1,
1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1.
		

Crossrefs

Cf. A160381, A130198 (single paradiddle), A010059, A010060, A374724.

Programs

  • Mathematica
    SubstitutionSystem[{1 -> {1, 0, 1, 1}, 0 -> {0, 1, 0, 0}}, {1}, {4}] // Flatten
  • PARI
    first(n,v=[1])=if(n>4*#v, v=first((n+3)\4)); my(u=List()); for(i=1,#v-1, listput(u,v[i]); listput(u,1-v[i]); listput(u,v[i]); listput(u,v[i])); my(t=vector(n-#u,i,if(i==2,1-v[#v],v[#v]))); for(j=1,#t, listput(u,t[j])); Vec(u) \\ Charles R Greathouse IV, Jul 31 2024

Formula

a(n) = A160381(n)+1 mod 2. - Kevin Ryde, Dec 28 2024
Showing 1-7 of 7 results.