Egyptian fraction by rolf

while 1:
 q=raw_input();x,y=map(int,q.split("/"));p=[]
 while x:d=y/x+(y%x>0);p+=["1/%d"%d];x=-y%x;y*=d
 print q,"="," + ".join(p)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page