Question: 2. An integer m is said to be a divisor of an integer n if the remainder of n divided by m is zero. For

 2. An integer m is said to be a divisor of

2. An integer m is said to be a divisor of an integer n if the remainder of n divided by m is zero. For example, the positive divisors of 9 are 1, 3, and 9. (a) Provide a non-iterative implementation of a C function num divisors_up_to_k that counts the number of positive divisors of a number that are less than or equal to k. For example, num_divisors_up_to_k(9,3) should return 2 since the only positive divisors of 9 that are less than or equal to 3 are 1 and 3. W num divisors_up_to_k(n,k) returns the number of positive divisors // of n that are less than or equal to k // requires: 1 ck can int num_divisors_up_to_k(int n, int k); Your implementation must use recursion. Hint: Perform recursion on k, not on n. 1 University of Windsor COMP-1410 - Winter 2021 School of Computer Science (b) An integer is prime if it has exactly two distinct positive divisors (itself and 1). Provide an implementation of is.prime that determines if a number is prime by calling your function num_divisors_up.to_k a single time. Note that by definition 1 is not a prime number V/ is prime () returns true if is a prine number and false otherwise // requires in bool is.prime(int n): (e) In the main function of al.c test your num divisors up to k and is.prime functions using asserts. Excluding the given examples you should include at least three tests and ensure that you have good test coverage including all edge cases

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!