Logo

Greetings from The On-Line Encyclopedia of Integer Sequences!

Hints

Search: id:A117966
Displaying 1-1 of 1 results found. page 1
     Format: long | short | internal | text      Sort: relevance | references | number      Highlight: on | off
A117966 Balanced ternary enumeration of integers; write n in ternary, and then replace 2's with (-1)'s. +0
4
0, 1, -1, 3, 4, 2, -3, -2, -4, 9, 10, 8, 12, 13, 11, 6, 7, 5, -9, -8, -10, -6, -5, -7, -12, -11, -13, 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, -27, -26, -28, -24, -23, -25, -30, -29, -31, -18, -17, -19, -15, -14, -16, -21, -20, -22, -36 (list; graph; listen)
OFFSET

0,4

COMMENT

A004488(n) = A117966^{-1}(-A117966(n)). I.e., if A117966(n) <= 0, A004488(n) = A117967(-A117966(n)), and if A117966(n) > 0, A004488(n) = A117968(A117966(n)).

REFERENCES

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

LINKS

A. Karttunen, Table of n, a(n) for n = 0..729

Ken Levasseur, The Balanced Ternary Number System

FORMULA

a(0)=0, a(3n)=3a(n), a(3n+1)=3a(n)+1, a(3n+2)=3a(n)-1. G.f. satisfies A(x) = 3A(x^3) + x - x^2.

EXAMPLE

7 in base 3 is 21; changing the 2 to a (-1) gives (-1)*3+1 = -2, so a(7) = -2.

PROGRAM

(MIT/GNU Scheme:) (define (A117966 n) (let loop ((z 0) (i 0) (n n)) (if (zero? n) z (loop (+ z (* (expt 3 i) (if (= 2 (modulo n 3)) -1 (modulo n 3)))) (1+ i) (floor->exact (/ n 3))))))

CROSSREFS

Cf. A117967, A117868, A001057, A004488.

Sequence in context: A143486 A021749 A088916 this_sequence A121891 A011414 A084511

Adjacent sequences: A117963 A117964 A117965 this_sequence A117967 A117968 A117969

KEYWORD

base,sign

AUTHOR

Frank Adams-Watters (FrankTAW(AT)Netscape.net), Apr 05 2006

EXTENSIONS

Antti Karttunen (His-Firstname.His-Surname(AT)gmail.com), May 19 2008, added the table for n=0..729 and the Scheme function.

page 1

Search completed in 0.002 seconds

Lookup | Welcome | Find friends | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
More pages | Superseeker | Maintained by N. J. A. Sloane (njas@research.att.com)

Last modified November 18 20:14 EST 2008. Contains 147244 sequences.


AT&T Labs Research