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.

A343317 a(n) is the least k >= 0 such that A343316(n, k) = n.

Original entry on oeis.org

0, 1, 4, 2, 4, 13, 11, 13, 7, 5, 7, 13, 11, 13, 40, 38, 40, 34, 32, 34, 40, 38, 40, 22, 20, 22, 16, 14, 16, 22, 20, 22, 40, 38, 40, 34, 32, 34, 40, 38, 40, 121, 119, 121, 115, 113, 115, 121, 119, 121, 103, 101, 103, 97, 95, 97, 103, 101, 103, 121, 119, 121
Offset: 0

Views

Author

Rémy Sigrist, Apr 11 2021

Keywords

Comments

To compute a(n): in the balanced ternary representation of n, replace each nonzero digit by "+1" and each nonleading zero by "-1".

Examples

			The first terms, alongside their balanced ternary representation (with "T" instead of digits "-1"), are:
  n   a(n)  bter(n)  bter(a(n))
  --  ----  -------  ----------
   0     0        0           0
   1     1        1           1
   2     4       1T          11
   3     2       10          1T
   4     4       11          11
   5    13      1TT         111
   6    11      1T0         11T
   7    13      1T1         111
   8     7      10T         1T1
   9     5      100         1TT
  10     7      101         1T1
  11    13      11T         111
  12    11      110         11T
  13    13      111         111
  14    40     1TTT        1111
  15    38     1TT0        111T
		

Crossrefs

Programs

  • PARI
    a(n) = if (n==0, 0, my (d=centerlift(Mod(n, 3))); if (d, +1, -1) + 3*a((n-d)\3))