Answer:
The program in Python is as follows:
#1
d = int(input("distance: "))
n = int(input("n: "))
arith_prog = []
for i in range(1,n+1,d):
arith_prog.append(i)
print(arith_prog)
#2
d = int(input("distance: "))
m = int(input("m: "))
n = int(input("n: "))
arith_prog = []
for i in range(m,n+1,d):
arith_prog.append(i)
print(arith_prog)
#3
r = int(input("ratio: "))
n = int(input("n: "))
geom_prog = []
m = 1
count = 0
while(m<n):
m = r**count
geom_prog.append(m)
count+=1
print(geom_prog)
Explanation:
#Program 1 begins here
This gets input for distance
d = int(input("distance: "))
This gets input for n
n = int(input("n: "))
This initializes the list, arith_prog
arith_prog = []
This iterates from 1 to n (inclusive) with an increment of d
for i in range(1,n+1,d):
This appends the elements of the progression to the list
arith_prog.append(i)
This prints the list
print(arith_prog)
#Program 2 begins here
This gets input for distance
d = int(input("distance: "))
This gets input for m
m = int(input("m: "))
This gets input for n
n = int(input("n: "))
This initializes the list, arith_prog
arith_prog = []
This iterates from m to n (inclusive) with an increment of d
for i in range(m,n+1,d):
This appends the elements of the progression to the list
arith_prog.append(i)
This prints the list
print(arith_prog)
#Program 3 begins here
This gets input for ratio
r = int(input("ratio: "))
This gets input for n
n = int(input("n: "))
This initializes the list, geom_prog
geom_prog = []
This initializes the element of the progression to 1
m = 1
Initialize count to 0
count = 0
This is repeated until the progression element is n
while(m<n):
Generate progression element
m = r**count
Append element to list
geom_prog.append(m)
Increase count by 1
count+=1
This prints the list
print(geom_prog)