Write a function to compute and return the value of the sum. Assume that the value of n is an argument of the function.
s = x − x^3/3! + x^5/5! − x^7/7! + . . . ± x^2n−1/(2n − 1)!
Then in main function use a while loop to read values of the parameter n and print the sum with each iteration.
Set double variables s = x (to hold the sum) and term = x (to hold an individual term in the series).
Loop the appropriate number of times, modifying term and adding to the sum. (This is a classic way of evaluating power series.)
If n is large it will tend to sin(x), for x in radians.
How can I go about solving this?
Write the above in code.
Incidentally, it is a LOOPING or REPETITION problem, not a RECURSIVE one (it doesn't call itself), so the title of your post is a little confusing. Also, given the speed at which factorials increase, you would be well advised not to calculate them individually - modify term as suggested above.