Advertisement
BERKYT

Untitled

Sep 18th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. #Найдите сумму всех чисел меньше 1000, кратных 3 или 5.
  2.  
  3. i = 0
  4. list = []
  5. while i < 1000:
  6.     if i % 3 == 0 or i % 5 == 0:
  7.         list.append(i)
  8.         print(i)
  9.     i += 1
  10.  
  11. sum = 0
  12. j = 0
  13. while j < len(list):
  14.     sum += list[j]
  15.     j += 1
  16.  
  17. print(sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement