How to do it this function question?

A function called sumofSeries that takes two parameters, the numbers x and n, and find the sum of the first n terms of the following series: x+(x +x2)+(x +x2 +x3)+ ....and return the result to the calling function. For example if x= 2 and n= 4, it should return:
2+(2 +22)+(2 +22 +23)+ (2 +22 +23 + 24) = 2+6+14+ 30 = 52 as the result.

Write the C++ statement(s) that invokes the function and the function definition for sumofSeries.

Answer in:

Statement that invoke/call the function: ?

Function definition: ?
1) resurction - there must be a way there.
2)loops

I am not going to put algorithm here.You try it first.If you fail I will put it here.
Maybe easier to think about it like this:

x = 2, n = 4

(21 * 4) + (22 * 3) + (23 * 2) + (24 * 1)
Topic archived. No new replies allowed.