OFFSET
0,3
LINKS
FORMULA
EXAMPLE
9 = "111" in primorial base (A002110(0) + A002110(1) + A002110(2) = 9) is converted to three 1-bits, with separating zeros, in binary as "10101" = A007088(21), thus a(9) = 21.
91 = "3001" in primorial base (91 = 3*A002110(3) + A002110(0)) is converted to binary number "1110001" = A007088(113), thus a(91) = 113. Note how two of the zeros come from the primorial base representation and the third zero is an extra separating zero inserted after each run of 1-bits apart from the rightmost 1-run.
PROG
(Scheme, two different implementations)
(define (A277022 n) (let loop ((n n) (z 0) (i 1) (j 0)) (if (zero? n) z (let* ((p (A000040 i)) (d (remainder n p))) (loop (quotient n p) (+ z (* (A000225 d) (A000079 j))) (+ 1 i) (+ 1 j d))))))
;; Another one based on given recurrence, utilizing memoization-macro definec:
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Sep 26 2016
STATUS
approved