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

let rec _a n a = match (n,a) with | (0,0) -> [] | (_,0) -> [] | _ -> match (n mod a) with | 0 -> a :: (_a n (a-1)) | _ -> _a n (a-1)
let _ = try while true do let n = read_int () in print_endline(string_of_int n^": "^ string_of_int(List.fold_left (+) 0 (_a n n))) done; with End_of_file -> ()

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

download

return to the top page