## Project Euler Challenge #1 : Threes and Fives

### Thursday, July 24, 2014

So I’ve been trying to improve my coding technique while thinking about some fun math problems, and Project EulerÂ will help me achieve exactly that. It’s unfortunate that they were hacked recent, so a lot of their functionality has been removed, but it will still confirm your answer.

My rules for these challenges:

- Searching Google for answers or algorithms is not allowed.
- Searching Google for builtin language libraries is allowed.
- After a solution is found, the first rule can be ignored (provided advance knowledge of future challenges is not present).

Anyway, below is Challenge #1 by me. This was pretty straightforward and brute-force, but it works. The only interesting thing I’m doing here is playing with the flexible definitions of True/False.

def euler1(n=1000): """Returns the sum of all numbers that possess either three or five as factors.""" for i in range(n): if not ((i % 3) * (i % 5)): s += i return s

Comments are closed, but you can leave a trackback.