Given an array A of N integers and two integers X and Y, find the number of integers in the array that are both less than or equal to X and divisible by Y.
a = [2, 6, 8, 9, 12, 5, 4, 11]
x = 10; y = 4;
counter = 0
for i in a:
if i <= x and i % y == 0:
counter += 1
print(counter)
Comments
Leave a comment