Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //counting the binomial coefficientes
- //check this shit one more time
- using namespace std;
- double binomial(int k, int n)
- {
- double coefficient;
- if (k == 0)
- return 1;
- else
- coefficient = double(n + 1 - k) / k * binomial(k - 1, n);
- return coefficient;
- }
- int main()
- {
- int n, k;
- cout << "Enter the value of k (upper coefficient): ";
- cin >> k;
- cout << "Enter the value of n (lower coefficient): ";
- cin >> n;
- cout << "Your binomial coefficient is " << binomial(k, n) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment