a>0 ve x>0 icin calisiyor.
#include <stdio.h>
//a>0 ve x>0 icin calisiyor
static double recursiveHesapla(int x, int a)
{
if(0 == a)
{
return 0;
}
double res = 1.0;
for(int i=0;i<a;i++)
{
res = res * (x-1);
}
res = res/a;
printf("%lf\n",res);
return res-recursiveHesapla(x, a-1);
}
//a>0 ve x>0 icin calisiyor
int main()
{
int varA, varX;
printf("Enter x>0: ");
scanf("%d",&varX);
if(varX<=0)
{
printf("Wrong x value");
return 0;
}
printf("Enter a>0: ");
scanf("%d", &varA);
if(varA<=0)
{
printf("Wrong a value");
return 0;
}
double result = recursiveHesapla(varX,varA);
int divA = varA;
divA%= 2;
if(0 == divA)
{
//potenz 2,4,6,8..ise sonuc negativ cikar
printf("result %lf",result*(-1));
}
else
{
//potenz 3,5,7,9..ise sonuc positiv cikar
printf("result %lf",result);
}
return 0;
}