#include<bits/stdc++.h>
using namespace std;
int binomial(int n, int k)
{
double r = 1;
int i;
for(i=1;i<=k;i++)
r = r * (n-k+i)/i;
return (int)(r+0.01);
}
int main()
{
int n, k;
cout << "Enter n && k :: ";
cin >> n >> k;
int p = binomial(n, k);
cout << p << endl;
return 0;
}
using namespace std;
int binomial(int n, int k)
{
double r = 1;
int i;
for(i=1;i<=k;i++)
r = r * (n-k+i)/i;
return (int)(r+0.01);
}
int main()
{
int n, k;
cout << "Enter n && k :: ";
cin >> n >> k;
int p = binomial(n, k);
cout << p << endl;
return 0;
}
Comments
Post a Comment