|
Search: id:A117967
|
|
|
| A117967 |
|
Positive part of inverse of A117966; write n in balanced ternary, and then replace (-1)'s with 2's. |
|
+0 5
|
|
| 0, 1, 5, 3, 4, 17, 15, 16, 11, 9, 10, 14, 12, 13, 53, 51, 52, 47, 45, 46, 50, 48, 49, 35, 33, 34, 29, 27, 28, 32, 30, 31, 44, 42, 43, 38, 36, 37, 41, 39, 40, 161, 159, 160, 155, 153, 154, 158, 156, 157, 143, 141, 142, 137, 135, 136, 140, 138, 139, 152, 150, 151, 146
(list; graph; listen)
|
|
|
OFFSET
|
0,3
|
|
|
REFERENCES
|
D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 2, pp. 173-175
|
|
LINKS
|
Ken Levasseur, The Balanced Ternary Number System
|
|
FORMULA
|
a(0) = 0, a(3n) = 3a(n), a(3n+1) = 3a(n)+1, a(3n-1) = 3a(n)+2.
If one adds this clause, then the function is defined on the whole Z: If n<0, then a(n) = A004488(a(-n)) (or equivalently: a(n) = A117968(-n)), and then it holds that a(A117966(n)) = n.
|
|
EXAMPLE
|
7 in balanced ternary is 1(-1)1, changing to 121 ternary is 16, so a(7)=16.
|
|
PROGRAM
|
(Two alternative definitions in MIT/GNU Scheme, defined for whole Z:)
(define (A117967 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967 (- z)))) (else (let* ((lp3 (expt 3 (A062153 z))) (np3 (* 3 lp3))) (if (< (* 2 z) np3) (+ lp3 (A117967 (- z lp3))) (+ np3 (A117967 (- z np3))))))))
(define (A117967v2 z) (cond ((zero? z) 0) ((negative? z) (A004488 (A117967v2 (- z)))) ((zero? (modulo z 3)) (* 3 (A117967v2 (/ z 3)))) ((= 1 (modulo z 3)) (+ (* 3 (A117967v2 (/ (- z 1) 3))) 1)) (else (+ (* 3 (A117967v2 (/ (+ z 1) 3))) 2))))
|
|
CROSSREFS
|
Cf. A117966. a(n) = A004488(A117968(n)). Bisection of A140263. A140267 gives the same sequence in ternary.
Sequence in context: A109681 A070367 A086308 this_sequence A068116 A019172 A133658
Adjacent sequences: A117964 A117965 A117966 this_sequence A117968 A117969 A117970
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
Frank Adams-Watters (FrankTAW(AT)Netscape.net), Apr 05 2006
|
|
EXTENSIONS
|
Antti Karttunen (His-Firstname.His-Surname(AT)gmail.com), May 19 2008, extended the formula's domain to all integers and added the Scheme code.
|
|
|
Search completed in 0.002 seconds
|