I can not fix the error of the last "factorial2" function, which in this case would be the factorial at the bottom of this calculation:
Program:
#include<stdio.h>#include<conio.h>doublefatorial(intn);doublefatorial2(intx,inty);intmain(){intn;intk;doubleA;printf("Digite os valores de N e K: ");
scanf("%d", &n);
scanf("%d", &k);
A = (float)fatorial(n) / fatorial2(n, k);
printf("Fatorial = %.0lf", A);
getch();
return 0;
}
double fatorial(int n)
{
double cima;
if ( n <= 1 )
return (1);
else
{
cima = n * fatorial(n - 1);
return (cima);
}
}
double fatorial2(int x, int y)
{
double baixo;
if ( (x <= 1) && (y <= 1))
return (1);
else
{
baixo = (x - y) * fatorial2((x - y) - 1);
return (baixo);
}
}