ProjectEuler Solved Question-1 ( with two Solutions)

  If we list all the natural numbers below 10 that are multiples of or 5we get 35and 9. The sum of these multiples is 23.


Find the sum of all the multiples of 3 or 5 below 1000.




# first way
def divisible_by_under(limit, divs):
return (i for i in range(limit) if any(i % div == 0 for div in divs))
print(sum(divisible_by_under(10, (3, 5))))

# 2nd way
print(sum([i for i in range(10) if i%3==0 or i%5==0]))

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions