Question: must use language c and recursion how do I fix this code to change the output to: 2 1 0 3 2 3 what is

must use language c and recursion

how do I fix this code to change the output to:

2

1

0

3

2

3

what is happening is that the outputs are just being added together. How to do I reset it everytime before n and k it goes through the function?

please re-write the correct code for me.

an example of what this program does is: if (n=9 and k=3) then the output should be 2 because in the range of 1-3 9 is only divisible by 1&3 so therefore only 2 numbers.

 must use language c and recursion how do I fix this

output but not what I want:

code to change the output to: 2 1 0 3 2 3

what I want:

2

1

0

3

2

3

1 2 3 4 5 #include #include #include 6 7 8 9 int c=0; int num_divisors_upto_k(int n, int k) { if(k==0) return c; else if(n%k==0) C+=1; return num_divisors_upto_k(n, k-1); 10 11 12 13 14 } 15 16 17 18 19 20 21 22 int main(void) [ printf("%d ", num_divisors_upto_k(9,3)); printf("%d ", num_divisors_upto_k(4,1)); printf("%d ", num_divisors_upto_k(5,0)); printf("%d ", num_divisors_upto_k(4,4)); printf("%d ", num_divisors_upto_k(3,9)); printf("%d ", num_divisors_upto_k(10,5)); 23 24 25 26 N

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!