Find a point's position on the integral Hilbert curve
R: 178 169

Room for improvement in this, but it's a start

f=function(d){x=y=0;s=1;while(s&lt;Inf){a=bitwAnd(1,d/2);b=bitwAnd(1,bitwXor(d,a));if(b==0){if(a==1){x=s-1-x;y=s-1-y};t=x;x=y;y=t};x=x+(s*a);y=y+(s*b);d=d/4;s=s*2};c(x,y)}


Test Run

&gt; f(0)
[1] 0 0
&gt; f(1)
[1] 1 0
&gt; f(9)
[1] 2 3
&gt; f(41)
[1] 7 6
&gt; f(325)
[1] 24  3