12375 - grometeic series   

Description

In mathematics, a geometric progression, also known as a geometric sequence, is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed, non-zero number called the common ratio. For example, the sequence 2, 6, 18, 54, ... is a geometric progression with common ratio 3.

Here, you are given an geometric  sequence, where the initial term is ‘a’, the total number of terms in this sequence is ‘n’, and the common ratio is ‘r’. Then, in this sequence: what is the value of the nth term, and what is the sum of all the terms?

note that : if use visual studio add #pragma warning(disable:4996) in first line to use scanf function

Input

Three integers separated by blanks. The first integer (a) is the initial term, where 0<a<10. The second integer (n) is the total number of terms in the sequence, where n>0 and n<10. The third integer (r) is the common ratio, where 0<r<4.

a,n,r should be type double and use %lf.

you should import lib math.h and use pow(r,n) to calculate r^n.

 

Output

Two values separated by a blank. The first value is the nth term of the sequence, and the second value is the sum of the sequence.  Note that you need to print '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss