Question: Write a function foo() that counts how many numbers between start and end (both included) are divisible by at least one of the numbers in

Write a function foo() that counts how many numbers between start and end (both included) are divisible by at least one of the numbers in divisors list.

For example, foo(5, 15, [3, 5]) should return 6, because among the numbers 5, 6, 7, . . . , 14, 15, we have 6, 9, 12, 15 which are divisible by 3 and 5, 10, 15 which are divisible by 5. So, altogether, we have six numbers divisible by 3 or 5 (or both). Note that 15 is divisible by both 3 and 5 but, of course, should be counted only once.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!