# Task 72 – Learn to Program

On my Day Zero List is the desire to learn to program; one of the things that people have been playing with in their down time here at Pennant Traning Systems is Project Euler:

### What is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

As I am poking about more and more with the Teensy USB Development Board [my note book of sorts] (I have four now, two Teensy 2.0s and two Teensy++ 2.0) and I am looking to play a bit more with the Arduino (or Arduino Clones), and since I am more of a mac user than anything else, I probably should look at learning Objective-C.

I am already using a Teensy / Arduino microcontroler for a number of projects of mine (Accessible Keyboard and My 1st ROV) so trying to use them, and Objective-C for Project Euler could make for an interesting challenge:

### Project Euler – Problem 1  code for a Teensy:

```/*
Project Euler - Problem 1

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.
*/

#include

int loops = 1;
int times = 1000;
long test = 1;
long result = 0;

void setup()
{
Serial.begin(38400);
delay (6000); // Give me time to start the serial consol
}

void loop()
{
if (loops < times)
{
// we are looking for numbers between test and times that are multiples of 3, or 5

// the %3 == 0 checks for the remainder being Zero I think;
// the == Logical Same,
// the || Logical OR
if (test %3 == 0 || test %5 == 0)
{
result = result + test;
Serial.println(test);
}
}
else
{
Serial.println("This has either Finished, or is broken.");
Serial.println("The Result is:");
Serial.println(result);
delay (600000);
}
test++;
loops++;
}```

Ok so it is probably not very well optimised, and could be a lot cleaner; but its a start. however importantly it gave me the correct answer.

As I progress through the Problems, my code should start to get optimised, and my maths skills should get better too.