The formula for C(n,k) can be expressed as the product (1+(n-k)/1) (1+(n-k)/2) (1+(n-k)/3) ... (1+(n-k)/k). Write a program to implement this (note that the terms in the product may not be integers). You should be able to handle much larger values of n and k now.
Warning: a naive implementation that ignores the type casting needed to convert between ints and intermediate data types will result in incorrect results - you can compare the results from previous tasks and this.
HOW DO I SOLVE THIS AND MAKE A PROGRAM FOR IT? I am new to c++ and haven't really learned much yet. I just have no idea how to implement the formula and write up a code.
You need to use a for loop. Other loop structures are possible but a for loop will do the job.
But why not start by writing a short program to get the values of n and k and calculate the first term? You should have enough training to use cin, cout and write the code for 1 + (n-k)/1)
Hint:
1 2 3 4 5 6 7
#include <iostream>
int main()
{
// your code goes here
return 0;
}