Thread: Pascal Triangle
View Single Post
  #3 (permalink)  
Old November 15th, 2005, 01:43 AM
mistry_bhavin mistry_bhavin is offline
Authorized User
 
Join Date: Mar 2004
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mistry_bhavin
Default

I write the following code ....
but it is not working properly

for(i=0;i<NUMBER;i++)
{
   for(j=0;j<=i;j++)
   {
      printf("%d \t",x(i,j));
   }
}

int x(int n, int k)
{
   if((k<=0) || (k>=n))
   {
      return 1;
   }
   else
   {
      return x(n-1,k) + x(n-1,k-1);
   }
}

Reply With Quote