#t219. 等差数列的第 k 项
等差数列的第 k 项
The k-th Term of an Arithmetic Progression
Problem Description
An arithmetic progression is a sequence in which, starting from the second term, the difference between each term and the previous one equals the same constant. This constant is called the common difference (usually denoted ), and the first term is called the first term (usually denoted ).
For example: an arithmetic progression with first term and common difference is: . Its 1st term is , its 2nd term is , its 3rd term is , and so on.
Now given the first term and the common difference of an arithmetic progression, find the value of its -th term.
Input Format
One line containing three integers , separated by spaces. .
Output Format
Output one integer: the value of the -th term of the arithmetic progression.
Sample Input
5 1 3
Sample Output
7
Sample Explanation
First term , common difference , the sequence is: . The 3rd term is .
Hint
- Three numbers on one line. The -th term = first term + (number of steps taken) × common difference — from the 1st term to the -th term, how many steps are taken?
- Check against the sample:
5 1 3→7.