/dev/Chiheb-Nexus

Solution de Projecteuler.net: Problème 1 (Python)

# ProjectEuler: 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.
#
####################
# Solution: 233168
# Best time: 0.00022363662719726562
####################

from time import time

start = time()
# Sum of the numbers < 1000 which are multiples of 3 or 5
number = sum(k for k in range(1000) if k % 3 == 0 or k % 5 == 0)
elapsed = time() - start
print("Solution: {0}\t Time elapsed: {1}".format(number, elapsed))