Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int coeficiente(int a,int b);
- int main(void){
- int a,b,coef;
- scanf("%d %d",&a,&b);
- while(b>a){
- printf("Reinsira os valores de a e b, relembrando que o segundo numero não pode ser maior que o primeiro.\n");
- scanf("%d %d",&a,&b);
- }
- coef = coeficiente(a,b);
- printf("%d",coef);
- return 0;
- }
- int coeficiente(int a,int b){
- if(b==0 && a>=1){
- return 1;
- }
- if(a==b){
- return 1;
- }
- else{
- return coeficiente(a-1,b) + coeficiente(a-1,b-1);
- }
- }
Add Comment
Please, Sign In to add comment