OFFSET
0,3
COMMENTS
LINKS
FORMULA
EXAMPLE
n Stern polynomial Encoded as a(n)
"unary-binary" number (-> decimal)
----------------------------------------------------------------
0 B_0(x) = 0 "0" 0
1 B_1(x) = 1 "1" 1
2 B_2(x) = x "10" 2
3 B_3(x) = x + 1 "101" 5
4 B_4(x) = x^2 "100" 4
5 B_5(x) = 2x + 1 "1101" 13
6 B_6(x) = x^2 + x "1010" 10
7 B_7(x) = x^2 + x + 1 "10101" 21
8 B_8(x) = x^3 "1000" 8
9 B_9(x) = x^2 + 2x + 1 "101101" 45
PROG
(Scheme)
;; Another implementation, more practical to run:
(define (A277020 n) (list_of_numbers_to_unary_binary_representation (A260443as_index_lists n)))
(definec (A260443as_index_lists n) (cond ((zero? n) (list)) ((= 1 n) (list 1)) ((even? n) (cons 0 (A260443as_index_lists (/ n 2)))) (else (add_two_lists (A260443as_index_lists (/ (- n 1) 2)) (A260443as_index_lists (/ (+ n 1) 2))))))
(define (add_two_lists nums1 nums2) (let ((len1 (length nums1)) (len2 (length nums2))) (cond ((< len1 len2) (add_two_lists nums2 nums1)) (else (map + nums1 (append nums2 (make-list (- len1 len2) 0)))))))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Oct 07 2016
STATUS
approved