81.6k views
4 votes
An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same. This in the sequence 1, 3, 5, 7, ..., the distance is 2 while in the sequence 6, 12, 18, 24, ..., the distance is 6. Given the positive integer distance and the integers m and n, create a list consisting of the arithmetic progression between (and including) m and n with a distance of distance (if m > n, the list should be empty.) For example, if distance is 2, m is 5, and n is 12, the list would be [5, 7, 9, 11]. Associate the list with the variable arith_prog.

User K Z
by
7.6k points

1 Answer

3 votes

Answer:[m, m+d, m+2d, - - - - -, n]

Explanation:

We know the formula for arithmetic progression is a_(n) = a_(1) + (n-1)d

Where a_(n) is the nth term of the sequence

a_(1) is the first term of the sequence

n is the number of the term like if we are talking about 7th term so the n is 7.

d is the difference between two successive terms.

For this problem we know our first term that is m, our last term that is n and our difference that is d.

For second term we will use the formula

a_(2) = m + (2-1)d

a_(2) = m + (1)d

a_(2) = m + d

Similarly,

a_(3) = m + (3-1)d

a_(3) = m + (2)d

a_(3) = m + 2d

User Cyberience
by
8.2k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories