Project Euler #2 Pseudocode

The Challenge

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Not super looking forward to this one because series were my worst Math subject. But hey, let’s give it a go. Fibonacci sequences are characterized by the fact that every number after the first two is the sum of the two preceding ones. Which can lead to some very simple (like the one I’ll use) to super complex formulas. Let’s write some pseudocode!

Include some stuff

Define some stuff if we can’t inline it

Going to need a loop

Going to need a Fibonacci sequence generator (can make one or use an existing one? Maybe both?)

Going to need to test for “evenness”

Going to need to sum it

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.