Egyptian fraction by @tttttanaka

#!ruby -n
def e n;a,b=n.map(&:to_i);b%a<1?"1/#{b/a}":"1/#{c=b/a+1} + "+e([a*c-b,b*c]);end;puts$_.chop+" = "+e($_.split'/')

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

download

return to the top page