Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long factorial(int);
- long factorial(int two){
- int three;
- long result = 1;
- for (three =1; three <= two; three++)
- result = result*three;
- return result;
- }
- int main(int argc, char **argv){
- int one;
- int two;
- int three;
- printf("Please enter the number of rows you wish to see in the pascal triangle\n");
- scanf("%d",&two);
- if (two > 20 || two < 1){
- printf("The value entered must be between 1 and 20 exclusively.");
- return 1;
- }
- for (one = 0; one < two; one++)
- {
- for (three = 0; three <= (two - one - 2); three++)
- printf(" ");
- for (three = 0; three <= one; three++)
- printf("%ld", factorial(one)/(factorial(three)*factorial(one-three)));
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement