Sum of Divisors for OCaml Golf Competition by eldesh

let f n = let xs = ref 0 in for i=1 to n do (if (n mod i==0) then xs:=!xs+i else ()) done;(string_of_int n) ^ ": " ^ (string_of_int !xs);;\x0d
while true do Printf.printf"%s\n"(f(int_of_string(read_line()))) done;;\x0d

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

download

return to the top page