Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- A = [randint(1, 1000) for i in range(1000)]
- count = 0
- for i in range(len(A)):
- for j in range(i + 1, len(A)):
- if (A[i] * A[j]) % 15 == 0:
- count += 1
- print(count)
- k15 = 0
- k5 = 0
- k3 = 0
- for i in range(len(A)):
- if A[i] % 15 == 0:
- k15 += 1
- elif A[i] % 5 == 0:
- k5 += 1
- elif A[i] % 3 == 0:
- k3 += 1
- k = len(A) - k15
- print(k * k15 + k3 * k5 + k15 * (k15 - 1) // 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement