Exercise Wednesday

You will get a chance to practice whiteboarding a lot during this course section. Time will be set aside during most class sessions at the discretion of your teacher. Use this time wisely to improve both your whiteboarding and functional programming skills!

Project Euler

Alternate problem #1 and #2 with your pair. Then alternate problem #3 and #4 from the Project Euler archives. If someone gets stuck, you may help your pair whiteboard a problem or brainstorm a solution.

Note: If you are concerned these problems may be too difficult for whiteboarding, you may choose to solve them ahead of time. You will then be expected to whiteboard and solve the problem without any notes (only what you can remember).

Ultimately, the most important thing is to work through the problem and make as much progress as you can. The goal is to practice and get more comfortable with whiteboarding and it's okay if you don't figure out the correct solution.

Problem #1

Solve Problem 1 on Project Euler using a functional approach. Here is the problem:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

Problem #2

Solve Problem 2 on Project Euler using a functional approach. Here is the problem:

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.