#B2032. Arithmetic Sequence: Find the nth Term
Arithmetic Sequence: Find the nth Term
Arithmetic Sequence: Find the nth Term
An arithmetic sequence is an interesting sequence where the difference between any two consecutive terms is constant.
Given the first two terms of the arithmetic sequence, \(a_1\) and \(a_2\), you are to compute the \(n\)th term of the sequence. The formula for the \(n\)th term is given by:
\( a_n = a_1 + (n-1) \times (a_2 - a_1) \)
inputFormat
The input consists of a single line containing three integers, \(a_1\), \(a_2\) and \(n\). \(a_1\) and \(a_2\) represent the first two terms of the arithmetic sequence and \(n\) represents the position of the term to be found.
outputFormat
Output a single integer: the \(n\)th term of the arithmetic sequence.
sample
1 3 5
9