Skip to content

Instantly share code, notes, and snippets.

@lv10
Created December 8, 2015 22:29
Show Gist options
  • Save lv10/5698f95b692779d7c81b to your computer and use it in GitHub Desktop.
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)
/*
*
* 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