- #1

anonim

- 39

- 2

- Homework Statement:
- Calculate math formula

- Relevant Equations:
- (n+r)!/(n!.r!)

I wirte code but it does not work. I entered n=5 and r=2, result is 0. And I want to calculate this recursively.

Code:

```
#include<stdio.h>
int func(int n, int r);
int main(){
int n,r;
int result=0;
printf("Enter the number:\n");
scanf("%d",&n);
printf("Enter the 2.number:\n");
scanf("%d",&r);
result=func(n,r);
printf("%d",result);
return(0);
}
int func(int n, int r){
if(r==1){
return(n);
}
if(n>0 && r>0){
return ((n+r) / (n*r))* func(n-1,r-1);
}
}
```