micseydel wrote:If you enjoyed this, you might want to check out Project Euler (especially problem 14).

Merci micseydel pour ton aide !

Thanks to you I cleaned a bit my script .

If you enjoyed this, you might want to check out Project Euler (especially problem 14).

What a great idea. I registered to the Project Euler some weeks ago but the problems were not as easy as it seems to be ! Here was my attempt to solve the first problem...

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.

- Code: Select all
`# -*- coding: utf-8 -*-`

def algorithm(a):

a -= 1

_list = []

while a > 0:

if a % 5 == 0:

_list.append(a)

elif a % 3 == 0:

_list.append(a)

a -= 1

return _list

def multiples_sum(_list):

multiples_sum = sum(_list)

return multiples_sum

def solve():

i = algorithm(1000)

e = multiples_sum(i)

print e

solve()

... As you can see, I've used the brute force solution which isn't very ingenious...