Don't like ads? PRO users don't see any ads ;-)
Guest

Raymond Euler Problem 1

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #Euler problem 1
  2. #Find the sum of all the multiples of 3 or 5 below 1000.
  3. list=[]
  4. multiples=[]
  5. for n in range (1,1000):
  6.     if n%3==0:
  7.         list.append(n)
  8.     elif n%5==0:
  9.         list.append(n)
  10.     elif n%15==0:
  11.         multiples.append(n)
  12. print sum(list)-sum(multiples)