use recursive
public static int c(int n, int k)
{
if(k==0 || k==n)
return 1;
return c(n-1, k-1) +c(n-1,k);
}
public static int c(int n, int k)
{
if(n<2 || k==0 || k==n) return 1;
int c=1;
for(int j=1; j<=k; j++)
{ c=c*(n-j+1)/j;
return c;
}
this code may not be relevant to your coding but the concept is almost the same...go figure. Don't ask me for any explanation ok
This post has been edited by Avex: Jan 28 2006, 01:54 AM
Jan 28 2006, 01:40 AM
Quote
0.0136sec
1.23
6 queries
GZIP Disabled