OFFSET
1,3
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..65536
FORMULA
EXAMPLE
For n = 25, "11001" in binary, the lengths of runs from the right are 1, 2 and 2, thus we form a product prime(1)^(1-1) * prime(2)^(2-1) * prime(3)^(2-1) = 2^0 * 3^1 * 5^1 = 15, and a(26) = 15.
PROG
(PARI) A286468(n) = { my(p=((n+1)%2), i=0, m=1); while(n>0, if(((n%2)==p), m *= prime(i), p = (n%2); i = i+1); n = n\2); m };
(Scheme)
(define (A286468 n) (fold-left (lambda (a r) (* (A003961 a) (A000079 (- r 1)))) 1 (binexp->runcount1list n)))
(define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))
;; Or by implementing the given recurrence:
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, May 17 2017
STATUS
approved