OFFSET
0,2
LINKS
EXAMPLE
29 = 0*64 + 1*16 + 3*4 + 1, i.e., 131 in quaternary and when digits are swapped in pairs, results 1013 in quaternary (1*64 + 0*16 + 1*4 + 3 = 71 in decimal), thus a(29)=71.
PROG
(Scheme:) (define (A126006 n) (let loop ((n n) (s 0) (p 1)) (cond ((zero? n) s) (else (loop (floor->exact (/ n 16)) (+ s (* p (+ (* 4 (modulo n 4)) (modulo (floor->exact (/ n 4)) 4)))) (* p 16))))))
(C) uint32_t a(uint32_t n) { return ((n & 0x33333333) << 2) | ((n & 0xcccccccc) >> 2); } /* Falk Hüffner, Jan 23 2022 */
(PARI) a(n) = my(d=Vecrev(digits(n, 4))); if (#d % 2, d = concat(d, 0)); fromdigits(Vecrev(vector(#d, i, d[i+(-1)^(i-1)])), 4); \\ Michel Marcus, Jan 23 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Jan 02 2007
STATUS
approved