Created
October 20, 2012 12:27
-
-
Save umutakturk/3923158 to your computer and use it in GitHub Desktop.
Revisions
-
K. Umut Aktürk revised this gist
Oct 20, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ using namespace std; float factorial(int n) { if (n == 1 || n == 0) { return 1; @@ -18,7 +18,7 @@ int factorial(int n) } } float combination(int n, int r) { return factorial(n) / (factorial(n-r) * factorial(r)); } @@ -32,7 +32,7 @@ int main() for (r = 0; r <= n; ++r) { cout << combination(n,r) << " "; } cout << endl; -
K. Umut Aktürk created this gist
Oct 20, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ /** * Binomial Coefficients * * @author K. Umut Aktürk <http://umut.me> * @date October 20, 2012 */ #include <iostream> using namespace std; int factorial(int n) { if (n == 1 || n == 0) { return 1; } else { return n * factorial(n-1); } } int combination(int n, int r) { return factorial(n) / (factorial(n-r) * factorial(r)); } int main() { int n, r; cout << "Enter the n value of (x+y)^n: "; cin >> n; for (r = 0; r <= n; ++r) { cout << combination(n, r) << " "; } cout << endl; return 0; }