DEV Community

Cover image for Multiples of 3 and 5 - Project Euler Solution
Deepak Raj
Deepak Raj

Posted on • Edited on • Originally published at codeperfectplus.com

5 2

Multiples of 3 and 5 - Project Euler Solution

Multiples of 3 and 5 - Project Euler Solution

Topic : Multiples of 3 and 5

Problem Statement:

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.

You can find the original question here -> Project Euler

Multiples of 3 and 5 in python

def multiples(n):
    sum = 0
    for i in range(n):
        if(i%3==0) or (i%5==0):
            sum += i
    return sum

print(multiples(1000))
Enter fullscreen mode Exit fullscreen mode

Share Your Solutions for Multiples of 3 and 5?

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up