How would I write a c program which will recursively compute the product of all even numbers greater than 0 and <= N, for values of N={16,7,9}, and print the results to an output file. For instance, if N=5, the product would be 4 x 2=8.
This recursive function in my program should accept a single value for N and for every call to that recursive function print out 1. how many times the recursive function has been called so far, 2. the value of the argument to the recursive function for this particular call, and 3. the value of the product so far(before the next recursive call). Main() is not the recurisve function. An example output for N=5 for what I want it to do might be:
Main: CALL ARGUMENT PRODUCT
RECU: 1 4 4
RECU: 2 2 8
MAIN: The product for N=5 is 8.
Here is what I got so far and had some help with other another programmer, but still stuck*NOTE(I know the program does not compute the right value, I need help on that too, plus I don't know what to do about passing the 3 values for N into the function)
code:
main()
{
int num=9;
recurse(num);
}
int recurse(int num)
{
if(num%2!=0)
num--;
int r=0;
if(num>0)
r=num*(num-2)+recurse(num-2);
printf("%d",r);
return r;
}