Update arithmeticProgressionSumFunc.py

This commit is contained in:
mahimadubey
2020-10-20 09:45:51 +05:30
committed by GitHub
parent 82a0e1433a
commit 327b74b89d

View File

@@ -10,7 +10,8 @@ def arithmeticProgressionSumFunc(maxd=100, maxa=100, maxn=100):
n = random.randint(4, maxn)
apString = str(a1) + ', ' + str(a2) + ', ' + str(a3) + ' ... '
problem = 'Find the sum of first ' + str(n) + ' terms of the AP series: ' + apString
solution = n * ((2 * a1) + ((n - 1) * d)) / 2
an=a1+(n-1)*d
solution = n * (a1+an) / 2
return problem, solution