OFFSET
0,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
K. Burde, Das Problem der Abzählreime und Zahlentwicklungen mit gebrochenen Basen [The problem of counting rhymes and number expansions with fractional bases], J. Number Theory 26(2) (1987), 192-209. [The author deals with the representation of n in fractional bases k/(k-1) and its relation to counting-off games (variations of Josephus problem). Here k = 4. See the review in MathSciNet (MR0889384) by R. G. Stoneham.]
FORMULA
To represent a number in base b, if a digit is greater than or equal to b, subtract b and carry 1. In fractional base a/b, subtract a and carry b.
MAPLE
a:= proc(n) `if`(n<1, 0, irem(n, 4, 'q')+a(3*q)*10) end:
seq(a(n), n=0..45); # Alois P. Heinz, Aug 20 2019
MATHEMATICA
p:= 4; q:= 3; a[n_]:= a[n]= If[n==0, 0, 10*a[q*Floor[n/p]] + Mod[n, p]]; Table[a[n], {n, 0, 40}] (* G. C. Greubel, Aug 20 2019 *)
PROG
(PARI) a(n) = my(p=4, q=3); if(n==0, 0, 10*a(q*(n\p)) + (n%p));
vector(40, n, n--; a(n)) \\ G. C. Greubel, Aug 20 2019
(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*(x//p))
i+=1
return Integer(''.join(str(x) for x in reversed(L)))
[basepqExpansion(4, 3, n) for n in [0..40]] # G. C. Greubel, Aug 20 2019
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
STATUS
approved