Euler Problem 104 – Hello Fibonacci

Fibonacci sequences are the “Hello World” of Haskell. So of course I thought that Euler 104 might be a nice, simple problem to tackle. NOT. I found lots of examples online, but I still have a steep learning curve to follow. I ended up piecing together a bunch of disconnected routines that make sense to me.

The only reason why this runs in less than a minute is due to Haskell’s laziness. Specifically, the second expression for the && isn’t executed unless the first passes. Calculating the lower order numbers is much faster than the higher order numbers.

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 )

Connecting to %s