%I #17 Aug 06 2023 23:51:12
%S 0,1,2,3,20,21,22,23,200,201,202,203,220,221,222,223,2000,2001,2002,
%T 2003,2020,2021,2022,2023,2200,2201,2202,2203,2220,2221,2222,2223,
%U 20000,20001,20002,20003,20020,20021,20022,20023,20200,20201,20202,20203,20220,20221
%N n written in fractional base 4/2.
%C To represent a number in base b, if a digit exceeds b, subtract b and carry 1. In fractional base a/b, subtract a and carry b.
%H G. C. Greubel, <a href="/A024630/b024630.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Ba#base_fractional">Index entries for sequences related to fractional bases</a>
%F a(n) = 2*A007088(floor(n/2)) + (n mod 2). - _Kevin Ryde_, Aug 06 2023
%p a:= proc(n) `if`(n<1, 0, irem(n, 4, 'q')+a(2*q)*10) end:
%p seq(a(n), n=0..45); # _Alois P. Heinz_, Aug 20 2019
%t p:=4; q:=2; a[n_]:= a[n]= If[n==0, 0, 10*a[q*Floor[n/p]] + Mod[n,p]]; Table[a[n], {n,0,50}] (* _G. C. Greubel_, Aug 20 2019 *)
%o (PARI) a(n) = p=4; q=2; if(n==0,0, 10*a(q*(n\p)) + (n%p));
%o vector(50, n, n--; a(n)) \\ _G. C. Greubel_, Aug 20 2019
%o (PARI) a(n) = fromdigits(binary(n>>1))<<1 + (n%2); \\ _Kevin Ryde_, Aug 06 2023
%o (Sage)
%o def basepqExpansion(p,q,n):
%o L, i = [n], 1
%o while L[i-1] >= p:
%o x=L[i-1]
%o L[i-1]=x.mod(p)
%o L.append(q*floor(x/p))
%o i+=1
%o L.reverse()
%o return Integer(''.join([str(x) for x in L]))
%o [basepqExpansion(4,2,n) for n in [0..50]] # _G. C. Greubel_, Aug 20 2019
%o (Python)
%o def a(n): return (int(bin(n>>1)[2:])<<1)+(n&1)
%o print([a(n) for n in range(50)]) # _Michael S. Branicky_, Aug 06 2023
%Y Cf. A007088 (binary), A024629 (base 3/2).
%K nonn,base,easy
%O 0,3
%A _David W. Wilson_