Advertisement
Farz0l1x

Untitled

Dec 3rd, 2023
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. from random import randint
  2. A = [randint(1, 1000) for i in range(1000)]
  3. count = 0
  4. for i in range(len(A)):
  5.     for j in range(i + 1, len(A)):
  6.         if (A[i] * A[j]) % 15 == 0:
  7.             count += 1
  8. print(count)
  9.  
  10. k15 = 0
  11. k5 = 0
  12. k3 = 0
  13. for i in range(len(A)):
  14.     if A[i] % 15 == 0:
  15.         k15 += 1
  16.     elif A[i] % 5 == 0:
  17.         k5 += 1
  18.     elif A[i] % 3 == 0:
  19.         k3 += 1
  20. k = len(A) - k15
  21. print(k * k15 + k3 * k5 + k15 * (k15 - 1) // 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement