login
Rebase n from 4 to 2. Replace 4^k with 2^k in quaternary expansion of n.
2

%I #27 Jan 04 2021 01:55:10

%S 1,2,3,2,3,4,5,4,5,6,7,6,7,8,9,4,5,6,7,6,7,8,9,8,9,10,11,10,11,12,13,

%T 8,9,10,11,10,11,12,13,12,13,14,15,14,15,16,17,12,13,14,15,14,15,16,

%U 17,16,17,18,19,18,19,20,21,8,9,10,11,10,11,12,13,12,13,14,15,14,15,16,17

%N Rebase n from 4 to 2. Replace 4^k with 2^k in quaternary expansion of n.

%C Notation: (4)[n](2).

%H Harry J. Smith, <a href="/A065362/b065362.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = 2*a(n/4) if n == 0 (mod 4); otherwise, a(n) = a(n-1) + 1. - _Clark Kimberling_, Aug 03 2012

%e 24 = 120 -> 1(4) + 2(2) + 0(1) = 8 = a(24).

%t t = Table[FromDigits[RealDigits[n, 4], 2], {n, 1, 100}] (* _Clark Kimberling_, Aug 02 2012 *)

%o (PARI) Rebase(x, b, c)= { local(d, e=0, f=1); while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=c); return(e) } { for (n=1, 1000, write("b065362.txt", n, " ", Rebase(n, 4, 2)) ) } \\ _Harry J. Smith_, Oct 17 2009

%o (Julia)

%o function a(n)

%o m, r, b = n, 0, 1

%o while m > 0

%o m, q = divrem(m, 4)

%o r += b * q

%o b *= 2

%o end

%o r end; [a(n) for n in 0:79] |> println # _Peter Luschny_, Jan 03 2021

%Y Cf. A065361.

%K base,easy,nonn

%O 1,2

%A _Marc LeBrun_, Oct 31 2001