Originally Posted by
anduril462
Are you referring to the tall parentheses with the two stacked numbers? If so, that's your select function or n combinations taken k at a time, often abbreviated nCk (or nCr).
Not quite. You're right that you do only need one for loop (excluding what's already defined in your fac function), but you need the general equation for the k-th term, to compute each time through the loop, not only the last, or n-th, term.
Your for loop will run from 0 to whatever number you specify (according to the problem, this is 'n', which can be 2, 4, 6 or 8). To keep with the terminology of your mathematical equations and the function parameters to select, I would call the loop variable 'k'.
Each iteration of the loop (the loop body) will contain basically 3 calculations that you will combine. The clue to these calculations comes from the last term in your "total = (n 0)..." equation. It's a little confusing, since in the last term, k is the same as n and your prof gave you everything in terms of n. If you think about it though, the top number of (n ?) is always n. It's the bottom number that changes/increments each time. Also, the number in front changes/increments each time through the loop.
So you have 3 parts to each term. The first is the sign (notice the + - + - pattern). This is your (-1)^? part. The second is the coefficient. This is your (n + 1) or (k + ?) term. The last is the stacked parenthetical thing. This is just a call to your select function. For each iteration through the loop, you calculate each of these accordingly and multiply the 3 parts.
Hope that's a little clearer.