fork download
  1. #include <stdio.h>
  2.  
  3. int comb(int a, int b)
  4. {
  5. if (b == 0 || b == a) {
  6. return 1;
  7. }
  8. return comb(a - 1, b) + comb(a - 1, b - 1);
  9. }
  10.  
  11. int main()
  12. {
  13. int a, b;
  14.  
  15. printf("a b\n");
  16. scanf("%d%d", &a, &b);
  17. printf("comb(%d, %d) = %d\n", a, b, comb(a, b));
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 1680KB
stdin
5 3
stdout
a b
comb(5, 3) = 10