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

A065367 Replace 3^k with (-3)^k in balanced ternary expansion of n.

Original entry on oeis.org

1, -4, -3, -2, 11, 12, 13, 8, 9, 10, 5, 6, 7, -34, -33, -32, -37, -36, -35, -40, -39, -38, -25, -24, -23, -28, -27, -26, -31, -30, -29, -16, -15, -14, -19, -18, -17, -22, -21, -20, 101, 102, 103, 98, 99, 100, 95, 96, 97, 110, 111, 112, 107, 108, 109, 104, 105, 106, 119, 120, 121, 116, 117, 118, 113
Offset: 1

Views

Author

Marc LeBrun, Oct 31 2001

Keywords

Comments

Notation: (3)< n >(-3)

Examples

			5 = +1(9)-1(3)-1(1) -> +1(9)-1(-3)-1(1) = 11 = a(5)
		

Crossrefs

A342802 Replace 2^k with (-3)^k in binary expansion of n.

Original entry on oeis.org

0, 1, -3, -2, 9, 10, 6, 7, -27, -26, -30, -29, -18, -17, -21, -20, 81, 82, 78, 79, 90, 91, 87, 88, 54, 55, 51, 52, 63, 64, 60, 61, -243, -242, -246, -245, -234, -233, -237, -236, -270, -269, -273, -272, -261, -260, -264, -263, -162, -161, -165, -164, -153, -152, -156, -155, -189, -188, -192, -191, -180, -179, -183, -182
Offset: 0

Views

Author

Wyatt Powers, Mar 21 2021

Keywords

Comments

All terms correspond to a sum of distinct powers of -3.

Examples

			For n = 0, a(0) = 0.
for n = 1, a(1) = -3^0 = 1.
for n = 2, a(2) = -3^1 = -3.
for n = 3, a(3) = -3^1 + -3^0 = -2.
for n = 4, a(4) = -3^2 = 9.
for n = 5, a(5) = -3^2 + -3^0 = 10.
		

Crossrefs

Cf. A005836 (sums of distinct powers of 3), A053985, A065369.

Programs

  • Mathematica
    (* Returns first 100 numbers in the sequence; assigned to the list, a *)
    a = Table[IntegerDigits[x, 2], {x, 0, 100}];
    For[i = 1, i <= Length[a], i++,
      For[j = 1, j <= Length[a[[i]]], j++,
       a[[i]][[j]] = ((a[[i]][[j]])*(-3)^(Length[a[[i]]] - j))
       ]
      ];
    For[i = 1, i <= Length[a], i++, a[[i]] = Total[a[[i]]]];
    a
  • PARI
    a(n) = my(b=Vecrev(binary(n))); sum(k=1, #b, b[k]*(-3)^(k-1)); \\ Michel Marcus, Mar 22 2021
    
  • PARI
    a(n) = fromdigits(binary(n),-3) \\ Kevin Ryde, Mar 22 2021
    
  • Python
    def a(n):
      return sum((-3)**k for k, b in enumerate(bin(n)[2:][::-1]) if b=='1')
    print([a(n) for n in range(64)]) # Michael S. Branicky, Mar 23 2021
Previous Showing 11-12 of 12 results.