Hi, I'm doing my homework and I'm stuck on this factorial part. I know this is the code for n! from my text:
But I need 2n! instead so I tried to modify the code to this:Code:#include <stdio.h>
double mfact(int);
main()
{
int m;
printf("Enter an integer m>0: ");
scanf("%d",&m);
printf("m! is: %g\n",mfact(m));
}
double mfact(int m)
{
if(m==1)return 1;
else return m*mfact(m-1);
}
Because I figured that 2n! = 2n*(2n-1) ... etc. so it would work but it's messed up. So in fact, I realized I don't get what this whole code is about. What is the mfact specifically?Code:#include <stdio.h>
double mfact(int);
main()
{
int m;
printf("Enter an integer m>0: ");
scanf("%d",&m);
printf("m! is: %g\n",mfact(m));
}
double mfact(int m)
{
if(m==1)return 2;
else return 2m*mfact(2m-1);
}