An arithmetic sequence is a sequence in which the difference between two neighboring terms is always the same. That fixed difference is called the common difference.
- 1, 3, 5, 7, 9, ...
- 2, 4, 6, 8, 10, ...
- 1, 5, 9, 13, 17, ...
- -1, -3, -5, -7, -9, ...
The sequence with first term a and common difference d runs a, a+d, a+2d, a+3d, so its n-th term is a+(n−1)d.
Write a program that finds which term of that sequence the number k is.