Re: PASCAL'S TRIANGLE
- From: jmcgill <jmcgill@xxxxxxxxxxxxxxxxx>
- Date: Wed, 04 Oct 2006 22:55:13 -0700
GUPTAJI wrote:
hi all,
can u give me the code to create a Pascal's Triangle........... and
yes, it should work
If you can make this print one more row correctly, I will be impressed.
#include <stdio.h>
unsigned long factorial(unsigned long a){
return a == 0UL ? 1UL : a * factorial(a-1UL);
}
int main(int argc, char **argv){
unsigned long row, num, val, fact;
for(row=0UL; row < 13UL; row++){
for(num=0UL; num <= row; num++){
val =
factorial(row) / (factorial(num) * factorial(row-num));
printf("%lu ", val);
}
printf("\n");
}
return 0;
}
.
- Follow-Ups:
- Re: PASCAL'S TRIANGLE
- From: Tak-Shing Chan
- Re: PASCAL'S TRIANGLE
- From: Richard Heathfield
- Re: PASCAL'S TRIANGLE
- References:
- PASCAL'S TRIANGLE
- From: GUPTAJI
- PASCAL'S TRIANGLE
- Prev by Date: Re: Problem with string manipulation
- Next by Date: Re: Help a practitioner with atomic access
- Previous by thread: Re: PASCAL'S TRIANGLE
- Next by thread: Re: PASCAL'S TRIANGLE
- Index(es):
Relevant Pages
|