floor, ceiling, and friends



There is a new verion of nummod on
http://www.unk.edu/facstaff/profiles/willisb/
(retrive the file nummod(2).zip.)  If you break it, I'll try to fix it.
Fun application:

unitfrac(r) := block([uf : [], q],
   if not(ratnump(r)) then error("The input to 'unitfrac' must be a
   rational number"),
   while r # 0 do (
        uf : cons(q : 1/ceiling(1/r), uf),
        r : r - q),
   reverse(uf));

(%i2) unitfrac(9/10);
(%o2) [1/2,1/3,1/15]
(%i3) apply("+",%);
(%o3) 9/10
(%i4) unitfrac(-9/10);
(%o4) [-1,1/10]
(%i5) apply("+",%);
(%o5) -9/10
(%i6) unitfrac(36/37);
(%o6) [1/2,1/3,1/8,1/69,1/6808]
(%i7) apply("+",%);
(%o7) 36/37

Barton