Egyptian fraction by clock

System.in.eachLine{t=it.split('/')*.toLong()
a=t[0];b=t[1];f=''
while(a>0){f+=' + 1/'+(c=(int)(a+b-1)/a);a=a*c-b;b*=c}
println it+' ='+f[2..-1]}

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

download

return to the top page