/*binomial.cpp Thsi function takes an x, y, and positive integer n and calculates (x+y)^n using the binomial theorem. */ #include #include using namespace std; int findfactorial(double num) { double fact(1); int i(1); while(i<=num) { fact*=i; i+=1; } return fact; } double nk(double n, double k) { double numerator, denominator, final; numerator = findfactorial(n); denominator = findfactorial(k)*findfactorial(n-k); final = numerator/denominator; return final; } int main() { double x, y, sum(0), n; cout<<"This function takes in a numerical value for x, a numerical value for y,\nand a positive integer for the exponent n to compute (x+y)^n using the binomial theorem."<