Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int fatorial(int n){
- int fat = 1, v[n], i;
- v[0]=1;
- for(i=1; i<n; i++){
- v[i]=v[i-1]+1;
- }
- for(i=1; i<n; i++){
- fat*=v[i];
- }
- return fat;
- }
- int main(){
- int n, p, nume, deno1, deno2, comb;
- printf("Digite n: ");
- scanf("%d", &n);
- printf("Digite p: ");
- scanf("%d", &p);
- nume=fatorial(n);
- deno1=fatorial(n-p);
- deno2=fatorial(p);
- comb=nume/(deno1*deno2);
- printf("\nCombinacao de %d escolhe %d = %d", n, p, comb);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement