Farey sequence by m.ukai

open List
let n=read_float()let rec f i j l=let m=((j/.i),(j,i))::remove_assoc(j/.i)l in
j>0.&f i(j-.1.)m||i=1.&[]<map(fun(a,(b,c))->Printf.printf"%.f/%.f
"b c)(Sort.list(<)m)||f(i-.1.)(i-.1.)m;;f n n[]

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

download

return to the top page