Split term and sum to 2 functions

This commit is contained in:
Anshita
2020-10-20 00:16:32 +05:30
101 changed files with 2091 additions and 858 deletions

View File

@@ -0,0 +1,12 @@
from .__init__ import *
def arithmeticProgressionSumFunc (maxd = 100, maxa = 100, maxn = 100):
d = random.randint (-1 * maxd, maxd)
a1 = random.randint (-1 * maxa, maxa)
a2 = a1 + d
a3 = a2 + d
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
return problem, solution