Skip to content

Commit

Permalink
Adds OCaml p006
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankKair committed Feb 11, 2020
1 parent 354fc48 commit 5c5421f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/006/p006.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
open Base
open Stdio

let squared x = x * x

let sum = List.fold ~init:0 ~f:(+)

let sum_of_sqs =
List.range 1 101
|> List.map ~f:(squared)
|> sum

let sq_of_sum =
List.range 1 101
|> sum
|> squared

let solve =
sq_of_sum - sum_of_sqs

let () =
printf "%d\n" solve

0 comments on commit 5c5421f

Please sign in to comment.