Advertisement
Stosswalkinator

Return multiples of 3 and 5, but it just loops infinitely

Jul 15th, 2013
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. # Set variables equal to a value.
  2. x = 3
  3. y = 5
  4. n = 1
  5.  
  6. while x * n < 1000: # when the answer is less than 1000, do the rest
  7.     print x * n # print the answer
  8.     n + 1 # then increment the multiplier by one
  9.  
  10.     if x * n >= 1000:
  11.         break # STOP!
  12.     else:
  13.         n + 1 # increment, maybe I don't need this
  14.  
  15. # same as above but with 5 now
  16. while y * n < 1000:
  17.     print y * n
  18.     n + 1
  19.     if y * m >= 1000:
  20.         break
  21.     else:
  22.         n + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement