How to do a Sigma in python 3 - Stack Overflow


Fri Oct 21 2022 09:00:07 GMT+0000 (UTC)

Saved by @ebeanes28 #python

def sigma(first, last, const):
    sum = 0
    for i in range(first, last + 1):
        sum += const * i
    return sum

# first : is the first value of (n) (the index of summation)
# last : is the last value of (n)
# const : is the number that you want to sum its multiplication each (n) times with (n)