Sum of Divisors for OCaml Golf Competition by jakahira(rakuda)

let s x=let rec f i a=if i=0 then a else f(i-1)(if x mod i=0 then i+a else a)in f(x/2)x;;while true do let l=read_line()in print_string(l^": ");print_int(s(int_of_string l));print_newline();done;;

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

download

return to the top page