[Solved] AP in Python using function


You can do that in this way, Also; you can specify how many terms you want in between first and last one by the third argument. Use simple mathematics.

def ap(arg1, arg2, d):
    diff = arg2 - arg1
    for i in range(d): yield arg1 + i*(diff/(d+1))  # division by d+1 

>>> list(ap(1, 6, 4))
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]

solved AP in Python using function