#The Calkin-Wilf construction for counting the rationals Help:=proc() print(` CW(x) , CWlist(L) , CWseq1(n) `): end: #CW(x): The two children (given a pair) of the fraction x CW:=proc(x) local a,b: a:=numer(x): b:=denom(x): [a/(a+b),(a+b)/b]: end: #CWlist(L): the list, in order of all the Calkin-Wilf children #of the list of fractions L CWlist:=proc(L) local i: [seq( op(CW(L[i])), i=1..nops(L) ) ]: end: #CWseq1(n): ALL the fractions in order, in the Calkin-Wilf #tree arranged from generation to generation, and each generation #is read from oldest to youngest for n generation CWseq1:=proc(n) local i, G,L: G:=[1]: L:=[]: for i from 0 to n-1 do L:=[ op(L), op(G)]: G:=CWlist(G): od: [seq(numer(L[i]),i=1..nops(L))]: end: