/* * To implement the Choose function : C(n,k) = (n/k) * C(n-1,k-1) using recursive function calls * @author-Karan Narain(karan@iitk.ac.in) * */ #include int choose(int n,int k) { //Base condition.The recursion should end when k becomes 1,and should return the corresponding value of n if(k==1) return n; else return (n*choose(n-1,k-1))/k; } int main() { int n,k,result; printf("Enter the values of n and k in the choose function.(n>=k,n>0,k>0)\n"); scanf("%d",&n); scanf("%d",&k); result=choose(n,k); printf("The value of C(%d,%d) is %d",n,k,result); return 0; }