Sum of Divisors for OCaml Golf Competition by tzo

let rec f(n,a,b)= if a>b then n else if b mod a==0 then f(n+a,a+1,b) else f(n,a+1,b);;\x0d
try while true do let n=read_int()in Printf.printf"%d: %d\n"n(f(0,1,n)); done\x0d
with _->();;\x0d

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

download

return to the top page