I’ve just started using Project Euler to give myself the kick up the backside I’ve been looking for to finally get me to learn programming. I’ve settled for Python as my language of choice since I wanted to start with something I had absolutely zero experience in. If I’d attempted it in BASIC, Javascript or PHP I would have solved the first two a little quicker (not that I’m at all proficient in any of those three), but I wanted to see how I would do from scratch.

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 1 is really simple, in theory and I thought it would take me no more than half an hour to write a program to solve it in Python. However, I am completely unfamiliar with the syntax of Python and because I’m not a real programmer I didn’t really know what the proper names were for the sorts of things I wanted my program to do. I tried Googling for some documentation that would help me get my head around arrays in Python, and came up with some stuff about ‘lists’, which the BASIC part of my brain had trouble accepting…anyway, I cracked it after **a few hours** with a rather inelegant brute force method.

The thing I really like, apart from the excitement of typing in the answer and waiting to find out if it’s accurate, is the solution forum afterwards, where previous solvers share their method. I have found after solving problems 1 and 2 that it’s not only my knowledge of Python that limits my solutions, but my knowledge of Maths! I think I’ll learn a lot about maths and number theory as a result of this, which isn’t bad since I just wanted to learn Python.

Problem 3 is all about factorizing primes, of which I know nothing, so I think this one will take a little longer for me to crack. But I’m really enjoying learning something new. It is also confirming my suspicions about the way kids learn best (well, kids like me, anyway). I’m desperate to earn my level one badge, which is gained after one solves 25 problems. Also, that little public badge that proudly claims I’ve solved 2 so far is quite nice too!

### Like this:

Like Loading...

*Related*

In Python:

In Yabasic:

Sorry, I couldn’t resist.

Ah, you’re finally learning Python! 🙂

Thanks, Tom. My method was much clumsier than that, since I didn’t know how to use for or range, so I hacked something together putting all of the numbers that met the criteria in an array (which I still don’t know the pythonesque name for…list? stack?) and then running a sum function on that array.

It’s an ugly piece of code, to be sure.

My solution to problem 3 was even uglier. My laptop went beserk when I tried to get it to find all of the factors of the composite number given, so while I was waiting for the initial program to stop running, I figured out which of the factors I had were primes and found the solution that way. Really, this feels like cheating, since I never actually wrote a program that popped the right number out…but I did learn a few things about primes and composite numbers in doing so.

You should definitely have a go at Euler…it’s great fun. I’m sure you’ll speed ahead of me in no time!