login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A126006 Involution of nonnegative integers: Swap the positions of digits q0 <-> q1, q2 <-> q3, q4 <-> q5, etc. in the base-4 expansion of n (where n = ... + q4*256 + q3*64 + q2*16 + q1*4 + q0). 6
0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 64, 68, 72, 76, 65, 69, 73, 77, 66, 70, 74, 78, 67, 71, 75, 79, 128, 132, 136, 140, 129, 133, 137, 141, 130, 134, 138, 142, 131, 135, 139, 143, 192, 196, 200, 204, 193, 197, 201, 205, 194, 198, 202, 206, 195 (list; graph; refs; listen; history; text; internal format)
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
Cf. A126007. A057300 is the analogous permutation based on swapping the binary digits of n.
Cf. A004442.
Sequence in context: A219747 A032819 A181684 * A164088 A109239 A056135
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Jan 02 2007
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 10:45 EDT 2024. Contains 371709 sequences. (Running on oeis4.)