idastan97

CSCI151 L18 P5

Oct 4th, 2016
113
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 fac(int s, int e){
  4.     if (s==e) return s;
  5.     return s*fac(s-1, e);  
  6. }
  7.  
  8. int nk(int n, int k){
  9.     if (k>n) return 0;
  10.     return fac(n, n-k+1)/fac(k, 1);
  11. }
  12.  
  13. int main(void) {
  14.     int n=5, k=2;
  15.     printf("%i", nk(n, k));
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment