login
A024630
n written in fractional base 4/2.
1
0, 1, 2, 3, 20, 21, 22, 23, 200, 201, 202, 203, 220, 221, 222, 223, 2000, 2001, 2002, 2003, 2020, 2021, 2022, 2023, 2200, 2201, 2202, 2203, 2220, 2221, 2222, 2223, 20000, 20001, 20002, 20003, 20020, 20021, 20022, 20023, 20200, 20201, 20202, 20203, 20220, 20221
OFFSET
0,3
COMMENTS
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.
FORMULA
a(n) = 2*A007088(floor(n/2)) + (n mod 2). - Kevin Ryde, Aug 06 2023
MAPLE
a:= proc(n) `if`(n<1, 0, irem(n, 4, 'q')+a(2*q)*10) end:
seq(a(n), n=0..45); # Alois P. Heinz, Aug 20 2019
MATHEMATICA
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 *)
PROG
(PARI) a(n) = p=4; q=2; if(n==0, 0, 10*a(q*(n\p)) + (n%p));
vector(50, n, n--; a(n)) \\ G. C. Greubel, Aug 20 2019
(PARI) a(n) = fromdigits(binary(n>>1))<<1 + (n%2); \\ Kevin Ryde, Aug 06 2023
(Sage)
def basepqExpansion(p, q, n):
L, i = [n], 1
while L[i-1] >= p:
x=L[i-1]
L[i-1]=x.mod(p)
L.append(q*floor(x/p))
i+=1
L.reverse()
return Integer(''.join([str(x) for x in L]))
[basepqExpansion(4, 2, n) for n in [0..50]] # G. C. Greubel, Aug 20 2019
(Python)
def a(n): return (int(bin(n>>1)[2:])<<1)+(n&1)
print([a(n) for n in range(50)]) # Michael S. Branicky, Aug 06 2023
CROSSREFS
Cf. A007088 (binary), A024629 (base 3/2).
Sequence in context: A089181 A028425 A224987 * A381582 A032809 A279180
KEYWORD
nonn,base,easy
STATUS
approved