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!)
A059095 List consisting of the representation of n in base 3 using digits -1, 0, 1. 27
1, 1, -1, 1, 0, 1, 1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 0, -1, 1, 0, 0, 1, 0, 1, 1, 1, -1, 1, 1, 0, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, 0, 1, -1, -1, 1, 1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, 1, 1, -1, 1, -1, 1, -1, 1, 0, 1, -1, 1, 1, 1, 0, -1, -1, 1, 0, -1, 0, 1, 0, -1, 1, 1, 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, -1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, -1, -1 (list; graph; refs; listen; history; text; internal format)
OFFSET
1
COMMENTS
Every natural number n has a unique representation as n = Sum_{i=1..k} e(i)*(3^i) for some k where e(i) is one of -1,0,1. Example: 25 = 27-3+1 = 1*3^3+0*3^2+(-1)*3^1+1*3^0 so its representation is 1,0,-1,1. So by writing n in this base 3 representation and juxtaposing we get the sequence: (1), (1,-1), (1,0), (1,1), (1,-1,-1), ...
REFERENCES
D. E. Knuth, The Art of Computer Programming, Addison-Wesley, Reading, MA, Vol 2, pp 173-175.
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..4560 (rows 1 <= n <= 729 = 3^6, flattened)
Wikipedia, Balanced Ternary
FORMULA
n = Sum_{0 <= k < A134021(n)} a(A134421(n)-2-k)*3^k, for n>0. - Reinhard Zumkeller, Oct 25 2007
EXAMPLE
From Michael De Vlieger, Jun 27 2020: (Begin)
First 27 rows, with terms aligned with powers of 3:
3^3 3^2 3^1 3^0
--------------------
1: 1;
2: 1, -1;
3: 1, 0;
4: 1, 1;
5: 1, -1, -1;
6: 1, -1, 0;
7: 1, -1, 1;
8: 1, 0, -1;
9: 1, 0, 0;
10: 1, 0, 1;
11: 1, 1, -1;
12: 1, 1, 0;
13: 1, 1, 1;
14: 1, -1, -1, -1;
15: 1, -1, -1, 0;
16: 1, -1, -1, 1;
17: 1, -1, 0, -1;
18: 1, -1, 0, 0;
19: 1, -1, 0, 1;
20: 1, -1, 1, -1;
21: 1, -1, 1, 0;
22: 1, -1, 1, 1;
23: 1, 0, -1, -1;
24: 1, 0, -1, 0;
25: 1, 0, -1, 1;
26: 1, 0, 0, -1;
27: 1, 0, 0, 0;
... (End)
MATHEMATICA
Array[If[First@ # == 0, Rest@ #, #] &[Prepend[IntegerDigits[#, 3], 0] //. {a___, b_, 2, c___} :> {a, b + 1, -1, c}] &, 32] // Flatten (* Michael De Vlieger, Jun 27 2020 *)
PROG
(Python)
def b3(n):
if n == 0: return []
carry, trailing = [(0, 0), (0, 1), (1, -1)][n % 3]
return b3(n//3 + carry) + [trailing]
t = []
for n in range(50):
t += b3(n)
print(t)
# Andrey Zabolotskiy, Nov 10 2019
(PARI) row(n) = apply(d->d-1, digits(n + 3^(logint(n<<1, 3)+1)>>1, 3)); \\ Kevin Ryde, Mar 04 2022
CROSSREFS
Cf. A117966, A134021 (row lengths, starting from row 1), A102283 (last each row), A065363 (row sums).
Cf. A003137 (ternary).
Sequence in context: A099990 A089939 A330550 * A187944 A105597 A188470
KEYWORD
tabf,sign,easy
AUTHOR
Avi Peretz (njk(AT)netvision.net.il), Feb 13 2001
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), Jul 20 2001
Offset corrected by Andrey Zabolotskiy, Nov 10 2019
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 March 29 08:13 EDT 2024. Contains 371265 sequences. (Running on oeis4.)