Created
December 8, 2015 22:29
-
-
Save lv10/5698f95b692779d7c81b to your computer and use it in GitHub Desktop.
Recursive Combinations Fomula implementation in C c(n,k)=c(n-1,k)+c(n-1,k-1)
This file contains 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 characters
/* | |
* | |
* Recursive Combinations Fomula implementation in C | |
* c(n,k)=c(n-1,k)+c(n-1,k-1) | |
* | |
* */ | |
long combine ( int n, int r ) | |
{ | |
if ( (n==r) || (r==0) || (n==0) ) | |
return 1; | |
return ( combine ( (n-1), r ) + combine ( (n-1), (r-1) )); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment