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-10 of 47 results. Next

A117967 Positive part of inverse of A117966; write n in balanced ternary and then replace (-1)'s with 2's.

Original entry on oeis.org

0, 1, 5, 3, 4, 17, 15, 16, 11, 9, 10, 14, 12, 13, 53, 51, 52, 47, 45, 46, 50, 48, 49, 35, 33, 34, 29, 27, 28, 32, 30, 31, 44, 42, 43, 38, 36, 37, 41, 39, 40, 161, 159, 160, 155, 153, 154, 158, 156, 157, 143, 141, 142, 137, 135, 136, 140, 138, 139, 152, 150, 151, 146
Offset: 0

Views

Author

Keywords

Examples

			7 in balanced ternary is 1(-1)1, changing to 121 ternary is 16, so a(7)=16.
		

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175

Crossrefs

Cf. A117966. a(n) = A004488(A117968(n)). Bisection of A140263. A140267 gives the same sequence in ternary.

Programs

  • Maple
    a:= proc(n) local d, i, m, r; m:=n; r:=0;
          for i from 0 while m>0 do
             d:= irem(m, 3, 'm');
             if d=2 then m:=m+1 fi;
             r:= r+d*3^i
          od; r
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, May 11 2015
  • Mathematica
    a[n_] := Module[{d, i, m = n, r = 0}, For[i = 0, m > 0, i++, {m, d} = QuotientRemainder[m, 3]; If[d == 2, m++]; r = r + d*3^i]; r];
    a /@ Range[0, 100] (* Jean-François Alcover, Jan 05 2021, after Alois P. Heinz *)
  • 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 a(n): return 0 if n==0 else a004488(a117968(n)) # Indranil Ghosh, Jun 06 2017
  • Scheme
    ;; Two alternative definitions in MIT/GNU Scheme, defined for whole Z:
    (define (A117967 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967 (- z)))) (else (let* ((lp3 (expt 3 (A062153 z))) (np3 (* 3 lp3))) (if (< (* 2 z) np3) (+ lp3 (A117967 (- z lp3))) (+ np3 (A117967 (- z np3))))))))
    (define (A117967v2 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967v2 (- z)))) ((zero? (modulo z 3)) (* 3 (A117967v2 (/ z 3)))) ((= 1 (modulo z 3)) (+ (* 3 (A117967v2 (/ (- z 1) 3))) 1)) (else (+ (* 3 (A117967v2 (/ (+ z 1) 3))) 2))))
    ;; Antti Karttunen, May 19 2008
    

Formula

a(0) = 0, a(3n) = 3a(n), a(3n+1) = 3a(n)+1, a(3n-1) = 3a(n)+2.
If one adds this clause, then the function is defined on the whole Z: If n<0, then a(n) = A004488(a(-n)) (or equivalently: a(n) = A117968(-n)) and then it holds that a(A117966(n)) = n. - Antti Karttunen, May 19 2008

A117968 Negative part of inverse of A117966; write -n in balanced ternary and then replace (-1)'s with 2's.

Original entry on oeis.org

2, 7, 6, 8, 22, 21, 23, 19, 18, 20, 25, 24, 26, 67, 66, 68, 64, 63, 65, 70, 69, 71, 58, 57, 59, 55, 54, 56, 61, 60, 62, 76, 75, 77, 73, 72, 74, 79, 78, 80, 202, 201, 203, 199, 198, 200, 205, 204, 206, 193, 192, 194, 190, 189, 191, 196, 195, 197, 211, 210, 212, 208, 207
Offset: 1

Views

Author

Keywords

Examples

			-7 in balanced ternary is (-1)1(-1), changing to 212 ternary is 23, so a(7)=23.
		

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175

Crossrefs

Cf. A117966. a(n) = A004488(A117967(n)). Bisection of A140263. A140268 gives the same sequence in ternary.

Programs

  • Python
    def a(n):
        if n==1: return 2
        if n%3==0: return 3*a(n//3)
        elif n%3==1: return 3*a((n - 1)//3) + 2
        else: return 3*a((n + 1)//3) + 1
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 06 2017

Formula

a(1) = 2, a(3n) = 3a(n), a(3n+1) = 3a(n)+2, a(3n-1) = 3a(n)+1.

A365711 Dirichlet inverse of balanced ternary enumeration of integers (A117966).

Original entry on oeis.org

1, 1, -3, -3, -2, -3, 2, -3, 0, -14, -8, 9, -13, -7, 6, 6, -5, 0, 8, 0, -6, -11, 7, 9, 15, -13, 0, -60, -26, 42, -31, -30, 24, -35, -31, 0, -37, -19, 39, 54, -38, 21, -34, 18, 0, -5, -17, -18, -18, 54, 15, 75, -14, 0, 58, 3, -24, -29, 25, 0, 29, -31, 0, -57, 71, 33, 14, -9, -21, -46, 22, 0, 35, -37, -45, -78, 2, 39
Offset: 1

Views

Author

Antti Karttunen, Sep 19 2023

Keywords

Crossrefs

Programs

Formula

a(1) = 1, and for n > 1, a(n) = -Sum_{d|n, dA117966(n/d) * a(d).
A011655(abs(a(n))) = A359377(n).

A246208 Permutation of nonnegative integers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 2*a(-(A117966(n))), otherwise a(n) = 1 + 2*a(A117966(n)-1).

Original entry on oeis.org

0, 1, 2, 5, 11, 3, 10, 4, 22, 45, 91, 9, 19, 39, 183, 7, 21, 23, 90, 44, 182, 20, 6, 8, 38, 18, 78, 157, 315, 37, 75, 151, 631, 17, 77, 13, 27, 55, 155, 311, 623, 111, 1263, 35, 303, 47, 181, 43, 365, 41, 89, 367, 15, 79, 314, 156, 630, 76, 16, 36, 150, 74, 302, 180, 46, 88, 14, 366, 42, 40, 364, 12, 54, 26, 110, 34
Offset: 0

Views

Author

Antti Karttunen, Aug 19 2014

Keywords

Comments

This is an instance of entanglement permutation, where complementary pair A117968/A117967 (negative and positive part of inverse of balanced ternary enumeration of integers, respectively) is entangled with complementary pair A005843/A005408 (even and odd numbers respectively), with a(0) set to 0 and a(1) set to 1.
Thus this shares with A140264 the property that apart from a(0) = 0, even numbers occur only in positions given by A117968, and odd numbers only in positions given by A117967.

Crossrefs

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

Programs

  • Python
    def a117966(n):
        if n==0: return 0
        if n%3==0: return 3*a117966(n//3)
        elif n%3==1: return 3*a117966((n - 1)//3) + 1
        else: return 3*a117966((n - 2)//3) - 1
    def a(n):
        if n<2: return n
        x=a117966(n)
        if x<1: return 2*a(-x)
        else: return 1 + 2*a(x - 1)
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 2*a(-(A117966(n))), otherwise a(n) = 1 + 2*a(A117966(n)-1).
As a composition of related permutations:
a(n) = A054429(A246210(n)).
a(n) = A246210(A246211(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)).

A246210 Permutation of nonnegative integers: a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 1 + 2*a(-(A117966(n))), otherwise a(n) = 2*a(A117966(n)-1).

Original entry on oeis.org

0, 1, 3, 6, 12, 2, 13, 7, 25, 50, 100, 14, 28, 56, 200, 4, 26, 24, 101, 51, 201, 27, 5, 15, 57, 29, 113, 226, 452, 58, 116, 232, 904, 30, 114, 10, 20, 40, 228, 456, 912, 80, 1808, 60, 464, 48, 202, 52, 402, 54, 102, 400, 8, 112, 453, 227, 905, 115, 31, 59, 233, 117, 465, 203, 49, 103, 9, 401, 53, 55, 403, 11, 41, 21, 81, 61
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 complementary pair A005843/A005408 (even and odd numbers respectively), with a(0) set to 0 and a(1) set to 1.
This implies that apart from a(1) = 1, even numbers occur only in positions given by A117967, and odd numbers only in positions given by A117968.

Crossrefs

Inverse: A246209.
Similar or related permutations: A054429, A246208, A246211.

Programs

  • Python
    def a117966(n):
        if n==0: return 0
        if n%3==0: return 3*a117966(n//3)
        elif n%3==1: return 3*a117966((n - 1)//3) + 1
        else: return 3*a117966((n - 2)//3) - 1
    def a(n):
        if n<2: return n
        x=a117966(n)
        if x<1: return 1 + 2*a(-x)
        else: return 2*a(x - 1)
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(0) = 0, a(1) = 1, and for n > 1, if A117966(n) < 1, a(n) = 1 + 2*a(-(A117966(n))), otherwise a(n) = 2*a(A117966(n)-1).
As a composition of related permutations:
a(n) = A054429(A246208(n)).
a(n) = A246208(A246211(n)).

A338245 Nonnegative values in A117966, in order of appearance.

Original entry on oeis.org

0, 1, 3, 4, 2, 9, 10, 8, 12, 13, 11, 6, 7, 5, 27, 28, 26, 30, 31, 29, 24, 25, 23, 36, 37, 35, 39, 40, 38, 33, 34, 32, 18, 19, 17, 21, 22, 20, 15, 16, 14, 81, 82, 80, 84, 85, 83, 78, 79, 77, 90, 91, 89, 93, 94, 92, 87, 88, 86, 72, 73, 71, 75, 76, 74, 69, 70, 68
Offset: 0

Views

Author

Rémy Sigrist, Oct 18 2020

Keywords

Comments

This sequence is a permutation of the nonnegative integers with inverse A338247 (the offset has been set to 0 so as to get a permutation).
There are only two fixed points: a(0) = 0 and a(1) = 1.

Examples

			A117966 = 0, 1, -1, 3, 4, 2, -3, -2, -4, 9, 10, 8, 12, 13, 11, 6, 7, 5, ...
We keep:  0, 1,     3, 4, 2,             9, 10, 8, 12, 13, 11, 6, 7, 5, ...
		

Crossrefs

See A338248 for a similar sequence.

Programs

  • PARI
    A117966(n) = subst(Pol(apply(x->if(x == 2, -1, x), digits(n, 3)), 'x), 'x, 3)
    print (select(v -> v>=0, apply(A117966, [0..107])))

Formula

a(0) = 0.
a(n) = A117966(A132141(n)) for any n > 0.

A338246 Nonpositive values in A117966, in order of appearance and negated.

Original entry on oeis.org

0, 1, 3, 2, 4, 9, 8, 10, 6, 5, 7, 12, 11, 13, 27, 26, 28, 24, 23, 25, 30, 29, 31, 18, 17, 19, 15, 14, 16, 21, 20, 22, 36, 35, 37, 33, 32, 34, 39, 38, 40, 81, 80, 82, 78, 77, 79, 84, 83, 85, 72, 71, 73, 69, 68, 70, 75, 74, 76, 90, 89, 91, 87, 86, 88, 93, 92, 94
Offset: 0

Views

Author

Rémy Sigrist, Oct 18 2020

Keywords

Comments

This sequence is a self-inverse permutation of the nonnegative integers (the offset has been set to 0 so as to get a permutation).

Examples

			A117966 = 0, 1, -1, 3, 4, 2, -3, -2, -4, 9, 10, 8, 12, 13, 11, 6, 7, 5, -9, ...
We keep:  0,     1,           3,  2,  4,                                 9, ...
		

Crossrefs

Cf. A003462 (fixed points), A117966, A157671, A338245.

Programs

  • PARI
    A117966(n) = subst(Pol(apply(x->if(x == 2, -1, x), digits(n, 3)), 'x), 'x, 3)
    print (-select(v -> v<=0, apply(A117966, [0..188])))

Formula

a(0) = 0.
a(n) = -A117966(A157671(n)) for any n > 0.
a(n) = n iff n belongs to A003462.

A365712 Sum of balanced ternary enumeration of integers (A117966) and its Dirichlet inverse.

Original entry on oeis.org

2, 0, 0, 1, 0, -6, 0, -7, 9, -4, 0, 21, 0, 4, 12, 13, 0, -9, 0, -10, -12, -16, 0, -3, 4, -26, 27, -32, 0, 72, 0, -1, 48, -10, -8, 36, 0, 16, 78, 94, 0, 54, 0, 50, 18, 14, 0, 3, 4, 74, 30, 91, 0, -27, 32, -25, -48, -52, 0, -30, 0, -62, -18, -74, 52, 18, 0, -25, -42, -66, 0, -36, 0, -74, -78, -110, -32, 0, 0, -40, 81
Offset: 1

Views

Author

Antti Karttunen, Sep 19 2023

Keywords

Crossrefs

Cf. also A365714, A365804.

Programs

Formula

a(n) = A117966(n) + A365711(n).
a(1) = 2, and for n > 1, a(n) = -Sum_{d|n, 1A117966(d) * A365711(n/d).

A246206 Permutation of natural numbers: a(1) = 1, if A117966(n) < 0, a(n) = A014580(a(-(A117966(n)))), otherwise a(n) = A091242(a(A117966(n)-1)).

Original entry on oeis.org

1, 2, 5, 9, 4, 13, 3, 37, 49, 64, 6, 10, 16, 81, 8, 20, 15, 351, 229, 451, 59, 11, 7, 41, 19, 73, 92, 114, 27, 36, 48, 140, 12, 53, 17, 24, 33, 69, 86, 107, 44, 170, 18, 63, 22, 410, 28, 524, 76, 271, 101, 14, 23, 687, 529, 895, 253, 25, 97, 213, 145, 333, 3413, 67, 2091, 31, 607, 103, 415, 4531, 47, 131, 87, 193, 55
Offset: 1

Views

Author

Antti Karttunen, Aug 19 2014

Keywords

Comments

Compare to the formula for A246164. However, instead of reversing binary representation, we employ here balanced ternary enumeration of integers (see A117966).

Crossrefs

Inverse: A246205.
Similar or related entanglement permutations: A246164, A245702, A246202, A246208, A246210.

Formula

a(1) = 1, and for n > 1, if A117966(n) < 0, then a(n) = A014580(a(-(A117966(n)))), otherwise a(n) = A091242(a(A117966(n)-1)).
As a composition of related permutations:
a(n) = A245702(A246208(n)).
a(n) = A246202(A246210(n)).
Showing 1-10 of 47 results. Next