Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started