fork download
  1. #include <stdio.h>
  2.  
  3. int combi(int n, int r){
  4. if(r==0){
  5. return 0;
  6. }
  7. else if(n==r){
  8. return 0;
  9. }
  10. else if(r==1){
  11. return n;
  12. }
  13. else{
  14. return combi(n-1,n-r)+combi(n-1,r);
  15. }
  16.  
  17. }
  18. int main(void){
  19. int n, r;
  20. n = 4, r = 2;
  21. printf("C(n=%d, r=%d) = %d\n", n, r, combi(n, r));
  22. return 0;
  23. }
  24.  
  25.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
C(n=4, r=2) = 4