login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A342802 Replace 2^k with (-3)^k in binary expansion of n. 1
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
All terms correspond to a sum of distinct powers of -3.
LINKS
EXAMPLE
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.
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
PROG
(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
CROSSREFS
Cf. A005836 (sums of distinct powers of 3), A053985, A065369.
Sequence in context: A152049 A246788 A365278 * A099887 A366348 A274827
KEYWORD
sign,look,easy,base
AUTHOR
Wyatt Powers, Mar 21 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 9 23:14 EDT 2024. Contains 372354 sequences. (Running on oeis4.)