m@main=getLine>>=putStrLn.f.reads>>m f[(a,s:b)]|x<-read b,d<-show.div(lcm a x)=d x++s:d a
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page