Connexion
Applications Google
Menu principal
Post a Comment On:
Scattered Thoughts
Untitled
No comments yet. -
1 – 0 of 0
I will write more about music notation later as I explore
LilyPond
. In this post I want to explore my answer to problem #6 of Project Euler:
What is the difference between the sum of the squares and the square of the sums?
I first defined a helper function:
let square i = i*i
Then the sum of the squares can be expressed as:
let sum_of_squares = {1..100} |> Seq.map square |> Seq.sum
And the square of the sum is:
let square_of_sum = {1..100} |> Seq.sum |> square
So that the desired difference is:
square_of_sum - sum_of_squares |> printfn "diff = %A"
And there's really nothing much more to say.
posted by Bernie at
4:23 PM
on Oct 22, 2009
Leave your comment
You can use some HTML tags, such as
<b>, <i>, <a>
Comment moderation has been enabled. All comments must be approved by the blog author.
Choose an identity
Google Account
You will be asked to sign in after submitting your comment.
Name/URL
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Name
URL
Anonymous
Comment with your Google account if you’d like to be able to manage your comments in the future. If you comment anonymously, you won’t be able to edit or delete your comment.
Learn more
Please prove you're not a robot
Untitled
No comments yet. -