Hello all, I'm very confused on this K factor stuff.....I understand that...12…*k indicates the product of consecutive numbers and therefore:

1*2*…*5

is actually

1*2*3*4*5 = 120

But I'm not sure how to write that as a code. I have the following information:

/* pseudocode for Binomial
  Coefficients */
  int binomial(int n, int k)
  {
     If (n < k) Then return (0)
     Else 
     {
        Set denominator = 1*2*...*k
        Set numerator = (n-k+1)*(n-k+2)*...*(n-1)*n
        return (numerator / denominator)
     } // else
     End if
  }

Does k represent 5 or just any number?? Is there some type of formula???

Recommended Answers

All 2 Replies

no. the k is passed in from main. So k can be any number.

For example, inside you main :

int main()
{
    binomial(5, 10); // here k = 10;
    binomial(3, 276); // here k is 276
}

no. the k is passed in from main. So k can be any number.

For example, inside you main :

int main()
{
    binomial(5, 10); // here k = 10;
    binomial(3, 276); // here k is 276
}

OK thx!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.