Guest User

Untitled

a guest
May 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #! -*- encoding: utf-8 -*-
  2. print("""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.
  3. Find the sum of all the multiples of 3 or 5 below 1000.""")
  4. print("")
  5.  
  6. def sumOfMultiples(multiplesList, toInt):
  7.     sum = 0
  8.     for i in range(toInt):
  9.         for d in multiplesList:
  10.             if i % d == 0:
  11.                 sum += i
  12.                 break
  13.     return sum;
  14.  
  15. if __name__ == "__main__":
  16.     print(sumOfMultiples([3,5], 1000));
Add Comment
Please, Sign In to add comment