Find the nearest Prime by sjoerd_visscher

m@main=do n<-readLn;print$head[z|z<-n:[n+x*y|x<-[1..],y<-[-1,1]],z#2>0];m
n#p|p*p>n=n
n#p|n`mod`p>0=n#(p+1)
n#p=0

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

download

return to the top page