Cancel fractions by recursive

while 1:
 a,b=n,d=map(int,raw_input().split('/'))
 while a:a,b=b%a,a
 print`n/b`+"/%i"%(d/b)*(b!=d)

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

download

return to the top page