Write three functions:
- factorial (k) that returns the factorial of the parameter k
(k!=1*2*....*k and 0!=1)
- power ( x, k) that calculates x^k (you can assume that the function works for x > 0 and k >=
0. If k = 0, function returns 1 for any positive value of x (there is a function in math library that finds power but in this assignment you
must write your own function)
- valueExp (x, n)
that calculates the approximate value of e^x . The function should use the following formula: e^x = 1 + x/(1!) + x^2/(2!) + x^3/(3!) +
x^4/(4!)+....
the value of parameter n denotes the amount of terms in the sum. Use function power to calculate the numerator and function factorial to
calculate the denominators in each term of the formula.
Write a program that reads a sequence of positive integers, the first non-positive integer terminates the input. Assume that the amount
of
input numbers is even. Starting from the first input number, consider the pair of inputs as value of x and the value of n and find the
approximated value of e^x using n terms of the given formula. The program prints the results on different lines printing the value of x and
the value of n as well as the value e^x. Use function valueExp to calculate the approximate value.