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.

Previous Showing 21-30 of 60 results. Next

A321464 Reverse nonzero digits in ternary expansion of n and convert back to decimal.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Nov 10 2018

Keywords

Comments

This sequence is a self-inverse permutation of nonnegative integers with fixed points A321473.
See A321474 for the decimal variant.
The binary variant simply corresponds to the identity (A001477).

Examples

			The first values at prime indices, alongside the corresponding ternary expansions, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   2     2       2          2
   3     3      10         10
   5     7      12         21
   7     5      21         12
  11    19     102        201
  13    13     111        111
  17    25     122        221
  19    11     201        102
  23    23     212        212
  29    55    1002       2001
  31    31    1011       1011
  37    37    1101       1101
  41    67    1112       2111
  43    49    1121       1211
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Block[{x = IntegerDigits[n, 3], t}, t = Flatten@ Position[x, 1 | 2]; x[[Reverse@ t]] = x[[t]]; FromDigits[x, 3]]; Array[a, 68, 0] (* Giovanni Resta, Sep 17 2019 *)
  • PARI
    a(n,base=3) = my (d=digits(n,base),t=Vecrev(select(sign,d)),i=0); for (j=1, #d, if (d[j], d[j] = t[i++])); fromdigits(d,base)

Formula

a(3 * n) = 3 * a(n).

A246211 Self-inverse permutation of natural numbers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 0, a(n) = A117967(1+a(-(A117966(n)))), otherwise a(n) = A117968(a(A117966(n)-1)).

Original entry on oeis.org

0, 1, 5, 22, 71, 2, 35, 15, 99, 225, 531, 66, 213, 516, 1899, 7, 73, 172, 307, 127, 1369, 36, 3, 52, 304, 148, 1246, 5408, 17461, 620, 1567, 5321, 41591, 194, 698, 6, 21, 69, 1489, 5165, 16975, 174, 142234, 643, 17287, 587, 695, 173, 5195, 72, 605, 4770, 23, 1761, 12051, 4175, 24134, 389, 137, 431, 3758, 945, 11964, 392, 419, 482, 11, 2872, 104, 37, 3830, 4, 49, 16
Offset: 0

Views

Author

Antti Karttunen, Aug 19 2014

Keywords

Comments

This is an instance of entanglement permutation, where complementary pair A117967/A117968 (positive and negative part of inverse of balanced ternary enumeration of integers, respectively) is entangled with the same pair in the opposite order: A117967/A117968, with a(0) set to 0 and a(1) set to 1.

Crossrefs

Related or similar permutations: A246207, A246208, A246209, A246210, A004488, A245812, A054429.

Formula

a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 0, a(n) = A117967(1+a(-(A117966(n)))), otherwise a(n) = A117968(a(A117966(n)-1)).

A325825 Square array giving the monic polynomial q satisfying q = gcd(P(x),P(y)) where P(x) and P(y) are polynomials in ring GF(3)[X] with coefficients in {0,1,2} given by the ternary expansions of x and y. The polynomial q is converted back to a ternary number, and then expressed in decimal.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 5, 3, 5, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 3, 1, 1, 3, 1, 4, 3, 1, 1
Offset: 1

Views

Author

Antti Karttunen, May 22 2019

Keywords

Comments

Array is symmetric, and is read by antidiagonals, with (x,y) = (1,1), (1,2), (2,1), (1,3), (2,2), (3,1), ...
If there is a polynomial q that satisfies q = gcd(P(x),P(y)), then also polynomial -q (which is obtained by changing all nonzero coefficients of q as 1 <--> 2, see A004488) satisfies the same relation, because there are two units (+1 and -1) in polynomial ring GF(3)[X]. Here we always choose the polynomial that is monic (i.e., with a leading coefficient +1), thus its base-3 encoding has "1" as its most significant digit, and the terms given here are all included in A132141.

Examples

			The array begins as:
   y
x      1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,  12,  ...
   --+-----------------------------------------------------
   1 | 1,  1,  1,  1,  1,  1,  1,  1,  1,   1,  1,  1,  ...
   2 | 1,  1,  1,  1,  1,  1,  1,  1,  1,   1,  1,  1,  ...
   3 | 1,  1,  3,  1,  1,  3,  1,  1,  3,   1,  1,  3,  ...
   4 | 1,  1,  1,  4,  1,  1,  1,  4,  1,   1,  4,  4,  ...
   5 | 1,  1,  1,  1,  5,  1,  5,  1,  1,   1,  5,  1,  ...
   6 | 1,  1,  3,  1,  1,  3,  1,  1,  3,   1,  1,  3,  ...
   7 | 1,  1,  1,  1,  5,  1,  5,  1,  1,   1,  5,  1,  ...
   8 | 1,  1,  1,  4,  1,  1,  1,  4,  1,   1,  4,  4,  ...
   9 | 1,  1,  3,  1,  1,  3,  1,  1,  9,   1,  1,  3,  ...
  10 | 1,  1,  1,  1,  1,  1,  1,  1,  1,  10,  1,  1,  ...
  11 | 1,  1,  1,  4,  5,  1,  5,  4,  1,   1, 11,  4,  ...
  12 | 1,  1,  3,  4,  1,  3,  1,  4,  3,   1,  4, 12,  ...
		

Crossrefs

Central diagonal: A330740 (after its initial zero).

Programs

  • PARI
    up_to = 105;
    A004488(n) = subst(Pol(apply(x->(3-x)%3, digits(n, 3)), 'x), 'x, 3);
    A325825sq(a,b) = { my(a=fromdigits(Vec(lift(gcd(Pol(digits(a,3))*Mod(1, 3),Pol(digits(b,3))*Mod(1, 3)))),3), b=A004488(a)); min(a,b); };
    A325825list(up_to) = { my(v = vector(up_to), i=0); for(a=1,oo, for(col=1,a, i++; if(i > up_to, return(v)); v[i] = A325825sq(col,(a-(col-1))))); (v); };
    v325825 = A325825list(up_to);
    A325825(n) = v325825[n];

A246209 Permutation of nonnegative integers: a(0) = 0, a(1) = 1, a(2n) = A117967(1+a(n)), a(2n+1) = A117968(a(n)).

Original entry on oeis.org

0, 1, 5, 2, 15, 22, 3, 7, 52, 66, 35, 71, 4, 6, 11, 23, 137, 194, 148, 213, 36, 73, 99, 172, 17, 8, 16, 21, 12, 25, 33, 58, 462, 601, 447, 643, 431, 620, 304, 516, 37, 72, 104, 173, 127, 225, 419, 587, 45, 64, 9, 19, 47, 68, 49, 69, 13, 24, 29, 59, 43, 75, 152, 197, 1273, 1734, 1334, 1940, 1294, 1740, 899, 1556, 1404, 1837, 945, 1567, 389, 698, 1246, 1761, 41
Offset: 0

Views

Author

Antti Karttunen, Aug 19 2014

Keywords

Comments

This is an instance of entanglement permutation, where complementary pair A005843/A005408 (even and odd numbers respectively) is entangled with complementary pair A117967/A117968 (positive and negative part of inverse of balanced ternary enumeration of integers, respectively), with a(0) set to 0 and a(1) set to 1.
This implies that the even positions contain only terms of A117967 and apart from a(1) = 1, the odd positions contain only terms of A117968.

Crossrefs

Inverse: A246210.
Related permutations: A054429, A246207, A246211.

Programs

  • Python
    from sympy.ntheory.factor_ import digits
    def a004488(n): return int("".join(str((3 - i)%3) for i in digits(n, 3)[1:]), 3)
    def a117968(n):
        if n==1: return 2
        if n%3==0: return 3*a117968(n//3)
        elif n%3==1: return 3*a117968((n - 1)//3) + 2
        else: return 3*a117968((n + 1)//3) + 1
    def a117967(n): return 0 if n==0 else a117968(-n) if n<0 else a004488(a117968(n))
    def a(n): return n if n<2 else a117967(1 + a(n//2)) if n%2==0 else a117968(a((n - 1)//2))
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(0) = 0, a(1) = 1, a(2n) = A117967(1+a(n)), a(2n+1) = A117968(a(n)).
As a composition of related permutations:
a(n) = A246207(A054429(n)).
a(n) = A246211(A246207(n)).

A289815 The first of a pair of coprime numbers whose factorizations depend on the ternary representation of n (see Comments for precise definition).

Original entry on oeis.org

1, 2, 1, 3, 6, 3, 1, 2, 1, 4, 10, 5, 12, 30, 15, 4, 10, 5, 1, 2, 1, 3, 6, 3, 1, 2, 1, 5, 14, 7, 15, 42, 21, 5, 14, 7, 20, 70, 35, 60, 210, 105, 20, 70, 35, 5, 14, 7, 15, 42, 21, 5, 14, 7, 1, 2, 1, 3, 6, 3, 1, 2, 1, 4, 10, 5, 12, 30, 15, 4, 10, 5, 1, 2, 1, 3, 6
Offset: 0

Views

Author

Rémy Sigrist, Jul 12 2017

Keywords

Comments

For n >= 0, with ternary representation Sum_{i=1..k} t_i * 3^e_i (all t_i in {1, 2} and all e_i distinct and in increasing order):
- let S(0) = A000961 \ { 1 },
- and S(i) = S(i-1) \ { p^(f + j), with p^f = the (e_i+1)-th term of S(i-1) and j > 0 } for any i=1..k,
- then a(n) = Product_{i=1..k such that t_i=1} "the (e_i+1)-th term of S(k)".
See A289816 for the second coprime number.
See A289838 for the product of this sequence with A289816.
By design, gcd(a(n), A289816(n)) = 1.
Also, the number of distinct prime factors of a(n) equals the number of ones in the ternary representation of n.
We also have a(n) = A289816(A004488(n)) for any n >= 0.
For each pair of coprime numbers, say x and y, there is a unique index, say n, such that a(n) = x and A289816(n) = y; in fact, n = A289905(x,y).
This sequence combines features of A289813 and A289272.
The scatterplot of the first terms of this sequence vs A289816 (both with logarithmic scaling) looks like a triangular cristal.
For any t > 0: we can adapt the algorithm used here and in A289816 in order to uniquely enumerate every tuple of t mutually coprime numbers (see Links section for corresponding program).

Examples

			For n=42:
- 42 = 2*3^1 + 1*3^2 + 1*3^3,
- S(0) = { 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, ... },
- S(1) = S(0) \ { 3^(1+j) with j > 0 }
       = { 2, 3, 4, 5, 7, 8,    11, 13, 16, 17, 19, 23, 25,     29, ... },
- S(2) = S(1) \ { 2^(2+j) with j > 0 }
       = { 2, 3, 4, 5, 7,       11, 13,     17, 19, 23, 25,     29, ... },
- S(3) = S(2) \ { 5^(1+j) with j > 0 }
       = { 2, 3, 4, 5, 7,       11, 13,     17, 19, 23,         29, ... },
- a(42) = 4 * 5 = 20.
		

Crossrefs

Programs

  • PARI
    a(n) =
    {
        my (v=1, x=1);
        for (o=2, oo,
            if (n==0, return (v));
            if (gcd(x,o)==1 && omega(o)==1,
                if (n % 3,    x *= o);
                if (n % 3==1, v *= o);
                n \= 3;
            );
        );
    }
    
  • Python
    from sympy import gcd, primefactors
    def omega(n): return 0 if n==1 else len(primefactors(n))
    def a(n):
        v, x, o = 1, 1, 2
        while True:
            if n==0: return v
            if gcd(x, o)==1 and omega(o)==1:
                if n%3: x*=o
                if n%3==1:v*=o
                n //= 3
            o+=1
    print([a(n) for n in range(101)]) # Indranil Ghosh, Aug 02 2017

Formula

a(A005836(n)) = A289272(n-1) for any n > 0.
a(2 * A005836(n)) = 1 for any n > 0.

A289816 The second of a pair of coprime numbers whose factorizations depend on the ternary representation of n (See Comments for precise definition).

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 3, 3, 6, 1, 1, 2, 1, 1, 2, 3, 3, 6, 4, 5, 10, 4, 5, 10, 12, 15, 30, 1, 1, 2, 1, 1, 2, 3, 3, 6, 1, 1, 2, 1, 1, 2, 3, 3, 6, 4, 5, 10, 4, 5, 10, 12, 15, 30, 5, 7, 14, 5, 7, 14, 15, 21, 42, 5, 7, 14, 5, 7, 14, 15, 21, 42, 20, 35, 70, 20, 35, 70
Offset: 0

Views

Author

Rémy Sigrist, Jul 12 2017

Keywords

Comments

For n >= 0, with ternary representation Sum_{i=1..k} t_i * 3^e_i (all t_i in {1, 2} and all e_i distinct and in increasing order):
- let S(0) = A000961 \ { 1 },
- and S(i) = S(i-1) \ { p^(f + j), with p^f = the (e_i+1)-th term of S(i-1) and j > 0 } for any i=1..k,
- then a(n) = Product_{i=1..k such that t_i=2} "the (e_i+1)-th term of S(k)".
See A289815 for the first coprime number and additional comments.
The number of distinct prime factors of a(n) equals the number of twos in the ternary representation of n.

Examples

			For n=42:
- 42 = 2*3^1 + 1*3^2 + 1*3^3,
- S(0) = { 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, ... },
- S(1) = S(0) \ { 3^(1+j) with j > 0 }
       = { 2, 3, 4, 5, 7, 8,    11, 13, 16, 17, 19, 23, 25,     29, ... },
- S(2) = S(1) \ { 2^(2+j) with j > 0 }
       = { 2, 3, 4, 5, 7,       11, 13,     17, 19, 23, 25,     29, ... },
- S(3) = S(2) \ { 5^(1+j) with j > 0 }
       = { 2, 3, 4, 5, 7,       11, 13,     17, 19, 23,         29, ... },
- a(42) = 3.
		

Crossrefs

Programs

  • PARI
    a(n) = my (v=1, x=1);                   \
           for (o=2, oo,                           \
               if (n==0, return (v));              \
               if (gcd(x,o)==1 && omega(o)==1,     \
                   if (n % 3,    x *= o);          \
                   if (n % 3==2, v *= o);          \
                   n \= 3;                         \
               );                                  \
           );
    
  • Python
    from sympy import gcd, primefactors
    def omega(n): return 0 if n==1 else len(primefactors(n))
    def a(n):
        v, x, o = 1, 1, 2
        while True:
            if n==0: return v
            if gcd(x, o)==1 and omega(o)==1:
                if n%3: x*=o
                if n%3==2:v*=o
                n //= 3
            o+=1
    print([a(n) for n in range(101)]) # Indranil Ghosh, Aug 02 2017

Formula

a(n) = A289815(A004488(n)) for any n >= 0.
a(A005836(n)) = 1 for any n > 0.
a(2 * A005836(n)) = A289272(n-1) for any n > 0.

A300222 In ternary (base-3) representation of n, replace 1's with 0's.

Original entry on oeis.org

0, 0, 2, 0, 0, 2, 6, 6, 8, 0, 0, 2, 0, 0, 2, 6, 6, 8, 18, 18, 20, 18, 18, 20, 24, 24, 26, 0, 0, 2, 0, 0, 2, 6, 6, 8, 0, 0, 2, 0, 0, 2, 6, 6, 8, 18, 18, 20, 18, 18, 20, 24, 24, 26, 54, 54, 56, 54, 54, 56, 60, 60, 62, 54, 54, 56, 54, 54, 56, 60, 60, 62, 72, 72, 74, 72, 72, 74, 78, 78, 80, 0, 0, 2, 0, 0, 2, 6, 6, 8, 0, 0, 2
Offset: 0

Views

Author

Antti Karttunen, Mar 14 2018

Keywords

Examples

			For n=46, which in base-3 (A007089) is 1201, replacing 1's with 0's gives 200, and as that is base-3 representation of 18 (= 2*(3^2) + 0*(3^1) + 0*(3^0)), a(46) = 18.
		

Crossrefs

Cf. A300822 (Moebius transform).

Programs

  • Mathematica
    Array[FromDigits[IntegerDigits[#, 3] /. 1 -> 0, 3] &, 93, 0] (* Michael De Vlieger, Mar 17 2018 *)
  • PARI
    A244042(n) = fromdigits(apply(x->(x%2), digits(n, 3)), 3);
    A300222(n) = (n - A244042(n));
    \\ Or directly as:
    A300222(n) = fromdigits(apply(x->(if (1==x, 0, x)), digits(n, 3)), 3);

Formula

a(n) = n - A244042(n) = 2*A244042(A004488(n)).
a(n) = 2*A005836(1+A289814(n)). [With the current starting offset 1 of A005836.]
a(n) = A300822(n) + A300824(n).

A352760 Lexigraphically earliest sequence of distinct nonnegative integers such that for any n >= 0, among the ternary digits of n and a(n) (counted with multiplicity) there are as many 1's as 2's.

Original entry on oeis.org

0, 2, 1, 6, 8, 5, 3, 7, 4, 17, 20, 11, 24, 26, 18, 15, 23, 9, 14, 19, 10, 21, 25, 16, 12, 22, 13, 35, 53, 29, 56, 62, 47, 33, 51, 27, 60, 74, 54, 78, 80, 71, 59, 72, 44, 45, 61, 32, 65, 77, 50, 34, 52, 28, 38, 55, 30, 57, 69, 42, 36, 46, 31, 63, 73, 48, 75, 79
Offset: 0

Views

Author

Rémy Sigrist, Jul 05 2022

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers.

Examples

			The first terms, alongside their ternary expansions, are:
  n   a(n)  ter(n)  ter(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     2       1          2
   2     1       2          1
   3     6      10         20
   4     8      11         22
   5     5      12         12
   6     3      20         10
   7     7      21         21
   8     4      22         11
   9    17     100        122
  10    20     101        202
  11    11     102        102
  12    24     110        220
		

Crossrefs

Cf. A004488, A039001 (fixed points), A331275, A355504.

Programs

  • PARI
    See Links section.

Formula

a(n) = n iff n belongs to A039001.
a(n) < 3^k iff n < 3^k.

A371256 The run lengths transform of the ternary expansion of n corresponds to the run lengths transform of the binary expansion of a(n).

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 16 2024

Keywords

Comments

For any v >= 0, the value v appears 2^A005811(v) times in the sequence.

Examples

			The first terms, alongside the ternary expansion of n and the binary expansion of a(n), are:
  n   a(n)  ter(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     1       2          1
   3     2      10         10
   4     3      11         11
   5     2      12         10
   6     2      20         10
   7     2      21         10
   8     3      22         11
   9     4     100        100
  10     5     101        101
  11     5     102        101
  12     6     110        110
  13     7     111        111
  14     6     112        110
  15     5     120        101
		

Crossrefs

See A371263 for a similar sequence.

Programs

  • PARI
    a(n) = { my (r = [], d, l, v = 0); while (n, d = n%3; l = 0; while ((n%3)==d, n\=3; l++;); r = concat(l, r);); for (k = 1, #r, v = (v+k%2)*2^r[k]-k%2); v }

Formula

a(A005823(n)) = n - 1.
a(A005836(n)) = n - 1.
a(A004488(n)) = a(n).
abs(a(n+1) - a(n)) <= 1.

A140265 Permutation of natural numbers: a(n) = A140263(n-1)+1.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, May 19 2008

Keywords

Crossrefs

Inverse: A140266.

Programs

  • Python
    from sympy import ceiling
    from sympy.ntheory.factor_ import digits
    def a004488(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3)
    def a117968(n):
        if n==1: return 2
        if n%3==0: return 3*a117968(n/3)
        elif n%3==1: return 3*a117968((n - 1)/3) + 2
        else: return 3*a117968((n + 1)/3) + 1
    def a117967(n): return 0 if n==0 else a117968(-n) if n<0 else a004488(a117968(n))
    def a001057(n): return -(-1)**n*ceiling(n/2)
    def a(n): return a117967(a001057(n - 1)) + 1 # Indranil Ghosh, Jun 07 2017
  • Scheme
    (define (A140265 n) (+ 1 (A140263 (- n 1))))
    
Previous Showing 21-30 of 60 results. Next