Skip to content

Project Euler Problem 28

November 21, 2011

Project Euler Problem 28 solution would be to fold the sequence of rectangles 1 to 500 each yielding its four corner numbers to the accumulated sum:

let problem028 () =
    [1..500]
    |> List.fold (fun (accum, last) n ->
            (accum + 4*last + 20*n, last + 8*n)) (1,1)
    |> fst

How amazingly compact!

About these ads

From → Project Euler

One Comment

Trackbacks & Pingbacks

  1. Project Euler Problem 58 « In F# Major

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: