Advertisement
hocikto19

Pascal triangel recursively

Oct 2nd, 2014
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int pascal(int n, int k);
  4.  
  5. void main(){
  6.     int n, k;
  7.     scanf("%d %d", &n, &k);
  8.     printf("%d\n", pascal(n, k));
  9. }
  10.  
  11. int pascal(int n, int k){
  12.     if (k == 0 || k == n)
  13.         return 1;
  14.     return (pascal(n - 1, k - 1) + pascal(n - 1, k));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement