algorithms

Algorithm implementations
git clone git://git.laack.co/algorithms.git
Log | Files | Refs | README

main.ml (370B)


      1 let readint () = 
      2     Scanf.scanf " %d" (fun x -> x)
      3 let testcase () =
      4     let n = readint () in
      5         let rec acc vl = if vl = 0 then 0 else ((vl mod 10) + (acc (vl / 10)))
      6         in (print_int (acc n); print_newline ())
      7 let () =
      8     let testcases = readint () in
      9         let rec acc idx = if idx = testcases then () else (testcase (); acc (idx+1))
     10         in acc 0