#C3406. Nth Term of a Geometric Progression
Nth Term of a Geometric Progression
Nth Term of a Geometric Progression
You are given the first two terms of a geometric progression (GP) and a positive integer N
. The task is to compute the Nth term of the GP. In a geometric progression, each term after the first is found by multiplying the previous term by a constant value known as the common ratio. Formally, the Nth term is given by:
$$a_N = a_1 \times r^{N-1}$$
where $$r = \frac{G2}{G1}$$, G1
is the first term, and G2
is the second term. Your program should read the three inputs from stdin and output the nth term to stdout.
inputFormat
The input consists of a single line containing three space-separated numbers: G1, G2 and N. Here, G1 and G2 are the first two terms of the geometric progression, and N (an integer) represents the position of the term to be calculated.
outputFormat
Output the Nth term of the geometric progression. If the result is an integer, print it without any decimal places.## sample
2 6 3
18