Jump to content
Fórum Script Brasil
  • 0

binomio de newton em C



Estou fazendo um programa pra faculdade que tem que calcular  uma soma dupla vezes um coef. B. Porém o valor de B é sempre zero e os da somatoria não são corretos.

#include <stdio.h>
#include <math.h>   
#include <stdlib.h>
double fatorial(double w){
double fat;
for(fat = 1; w > 1; w = w - 1)
fat = fat * w;
 return fat;

  int main(){
        int p, l, k, i, N;
        double B, func, n, m, somatorio1, somatorio2, soma = 0., b;;
    printf("Digite os valores de n m :\n");
    scanf("%lf %lf", &n, &m);
    N = n + m;
    for(k = 0; k <= N; k++){
    func =  fatorial(k) / ( pow(2, N) * fatorial(n) * fatorial(m));
        B = sqrt(func);

    for(p = 0;p <= n; p++){
        for(l = 0;l <= m; l++){ 
            if(p+l == k){
                somatorio1 = pow(-1, p) *(fatorial(n) / (fatorial(p) * fatorial(n - p)));
                somatorio2 = fatorial(m) / (fatorial(l) * fatorial(m - l)); 
                soma = soma + somatorio1 * somatorio2;
printf("%d %lf\n", k, soma);
       return 0;

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...