fork download
  1. #include <stdio.h>
  2.  
  3. int comb(int n, int r){
  4. int ans=0;
  5. if(r==1){
  6. return n;
  7. }
  8. else{
  9. ans=(comb(n-1, r-1)*n)/r;
  10. return ans;
  11. }
  12.  
  13. }
  14. int main(void) {
  15. printf("%d\n", comb(5,2));
  16. printf("%d\n", comb(6,3));
  17. printf("%d\n", comb(7,4));
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
10
20
35