Egyptian fraction by twobit

while 1:
\x09a=raw_input();x,y=map(int,a.split("/"));a+=" ="
\x09while x:q=-y/x;a+=" 1/%d +"%-q;x=-y%x;y*=-q
\x09print a[:-2]

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

download

return to the top page