#C3387. Geometric Sequence Generator
Geometric Sequence Generator
Geometric Sequence Generator
You are given three integers a, r, and n representing the first term, the common ratio, and the number of terms of a geometric sequence respectively. The geometric sequence is defined by the formula:
$$a_i = a \cdot r^{i-1}$$
Your task is to generate the first n elements of this sequence and output them as a comma-and-space separated string.
- For example, if a = 2, r = 3, and n = 4, the sequence is: 2, 6, 18, 54.
Please note that the program must read input from stdin
and write the result to stdout
.
inputFormat
The input consists of a single line containing three space-separated integers: a
(the first term), r
(the common ratio), and n
(the number of terms).
outputFormat
Output a single line containing the first n
elements of the geometric sequence, separated by a comma and a space.
2 3 4
2, 6, 18, 54