Answer to Question #303626 in Python for naman

Question #303626

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.

1
Expert's answer
2022-02-28T01:06:52-0500
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) 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS