OFFSET
0,3
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
MATHEMATICA
IntegerReverse[Range[0, 100], 4] (* Paolo Xausa, Aug 07 2024 *)
PROG
(Haskell)
import Data.List (unfoldr)
a030103 n = foldl (\v d -> 4*v + d) 0 $ unfoldr dig n where
dig x = if x == 0 then Nothing else Just $ swap $ divMod x 4
-- Reinhard Zumkeller, Oct 10 2011
(PARI) a(n, b=4)=subst(Polrev(base(n, b)), x, b) /* where */
base(n, b)={my(a=[n%b]); while(0<n\=b, a=concat(n%b, a)); a} \\ M. F. Hasler, Nov 04 2011
(MIT/GNU Scheme)
(define (A030103 n) (if (zero? n) n (let ((uplim (+ (A000523 n) (- 1 (modulo (A000523 n) 2))))) (add (lambda (i) (* (bit_i n (+ i (expt -1 i))) (expt 2 (- uplim i)))) 0 uplim))))
(define (bit_i n i) (modulo (floor->exact (/ n (expt 2 i))) 2))
;; The functional add implements sum_{i=lowlim..uplim} intfun(i):
(define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
;; Antti Karttunen, Oct 30 2013
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved