Project Euler + Python

For a while I’ve been meaning to play with python but I could never think of something to do with it; so I decided to try and solve as many problems in Project Euler as I can.

Here is my mercurial repository on bitbucket: https://bitbucket.org/TWith2Sugars/project-euler

This is my attempt at the first problem so far:

Problem: http://projecteuler.net/index.php?section=problems&id=1
source: https://bitbucket.org/TWith2Sugars/project-euler/src/813d5ec90687/python/1.py

result = 0
for i in range(1000):
    if i % 5 == 0:
	    result += i
    elif i % 3 == 0:
	    result += i

print(result)

Leave a Reply