OFFSET
0,3
LINKS
FORMULA
a(0) = 0, and given d=1, 2 or 3, then a((d*(4^i))+r)
= (4^i) + a(A057300(r)), if d=1 and i is even, or if d=2 and i is odd
= 2*(4^i) + a(A057300(r)), if d=3,
= 3*(4^i) + a((4^i)-1-r) in other cases.
From Alan Michael Gómez Calderón, May 06 2025: (Start)
a((2 + 16^n)*2^(-1 + 4*m)) = 4^(2*(n + m) - 1) + (11*16^m - 2)/3. (End)
MAPLE
A057300 := proc(n)
option remember;
`if`(n=0, 0, procname(iquo(n, 4, 'r'))*4+[0, 2, 1, 3][r+1])
end proc:
A163355 := proc(n)
option remember ;
local d, base4, i, r ;
if n <= 1 then
return n ;
end if;
base4 := convert(n, base, 4) ;
d := op(-1, base4) ;
i := nops(base4)-1 ;
r := n-d*4^i ;
if ( d=1 and type(i, even) ) or ( d=2 and type(i, odd)) then
4^i+procname(A057300(r)) ;
elif d= 3 then
2*4^i+procname(A057300(r)) ;
else
3*4^i+procname(4^i-1-r) ;
end if;
end proc:
seq(A163355(n), n=0..100) ; # R. J. Mathar, Nov 22 2023
PROG
(Scheme) (define (A163355 n) (let* ((i (floor->exact (/ (A000523 n) 2))) (dd (modulo (floor->exact (/ n (expt 4 i))) 4)) (r (if (zero? n) n (modulo n (expt 4 i))))) (cond ((zero? n) n) ((= 0 dd) (A163355 r)) ((= (+ 1 (modulo i 2)) dd) (+ (expt 4 i) (A163355 (A057300 r)))) ((= 3 dd) (+ (* 2 (expt 4 i)) (A163355 (A057300 r)))) (else (+ (* 3 (expt 4 i)) (A163355 (- (expt 4 i) 1 r)))))))
(PARI)
A057300(n) = { my(t=1, s=0); while(n>0, if(1==(n%4), n++, if(2==(n%4), n--)); s += (n%4)*t; n >>= 2; t <<= 2); (s); };
CROSSREFS
Inverse: A163356. A163357 & A163359 give two variants of Hilbert curve in N x N grid. Cf. also A163332.
KEYWORD
nonn
AUTHOR
Antti Karttunen, Jul 29 2009
EXTENSIONS
Links to further derived sequences added by Antti Karttunen, Sep 21 2009
STATUS
approved
