Arithmetic Progression
Accept three values related to an arithmetic progression - number of terms T, initial value I and the difference between the terms D. Print the values of the T terms.
Input Format :
The first line contains the number of terms T.
The second line contains the initial value I.
The third line contains the difference between the terms D.
Output Format :
The first line contains the values of T terms in the progression.
Example Input/Output 1 :
Input :
5
1
2Output :
1 3 5 7 9
Example Input/Output 2:
Input :
6
5
20Output :
5 25 45 65 85 105
PYTHON3 CODE:
m=int(input())
a=int(input())
d=int(input())
n=1
for i in range(m):
print(a+(n-1)*d,end=' ')
n+=1
Accept three values related to an arithmetic progression - number of terms T, initial value I and the difference between the terms D. Print the values of the T terms.
Input Format :
The first line contains the number of terms T.
The second line contains the initial value I.
The third line contains the difference between the terms D.
Output Format :
The first line contains the values of T terms in the progression.
Example Input/Output 1 :
Input :
5
1
2Output :
1 3 5 7 9
Example Input/Output 2:
Input :
6
5
20Output :
5 25 45 65 85 105
PYTHON3 CODE:
m=int(input())
a=int(input())
d=int(input())
n=1
for i in range(m):
print(a+(n-1)*d,end=' ')
n+=1
0 Comments