#include<stdio.h>
//binomial coefficient function
double Ni(
int deg, //degree
int b //for binomial
)
{
if( deg < 0 )
return 0.0;
else if ( deg == 0 )
return 1.0;
else{
double temp = 1.0;
for(int i=1; i<=b;i++ ){
temp = temp* (double)(deg-i+1)/i;
printf("%f\n", temp);
}
return temp;
}
}
void main ()
{
int a=10, b=3;
double bin;
bin = Ni(a, b);
printf("\n=============\n");
printf("%f\n", bin);
}
binomial coefficient c code
Saturday, March 25, 2017
loading..
Subscribe to:
Post Comments (Atom)
No comments