Saturday, May 8, 2010

Problem 6: Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

This one is simple.

let problem6a =
    let range = {1..100}
    let sumOfSquares = range |> Seq.sumBy (fun x -> x * x)
    let sumSquared = pown (range |> Seq.sum) 2
    sumSquared - sumOfSquares

2 comments: