Skip to content

Instantly share code, notes, and snippets.

@anshumanatri
Created March 12, 2009 10:14
Show Gist options
  • Save anshumanatri/77997 to your computer and use it in GitHub Desktop.
Save anshumanatri/77997 to your computer and use it in GitHub Desktop.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
int b[10][10];
int binomial(int n, int k)
{
int i,j;
for(i=0;i<=n;i++)
for(j=0;j<=(i<k?i:k);j++)
if(j==0 || j==i)
b[i][j]=1;
else
b[i][j]=b[i-1][j-1]+b[i-1][j];
return b[n][k];
}
void main()
{
clrscr();
int n,k;
cout<<"\nEnter the value of n:\t";cin>>n;
cout<<"\nEnter the value of k:\t";cin>>k;
cout<<"NcK:\t"<<binomial(n,k);
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment