Easy Tutorial
❮ Python String Rindex Ref Math Frexp ❯

Python Calculation of the Sum of Cubes of n Natural Numbers

Python3 Examples

Calculation Formula 1

Implementation Requirements:

Input: n = 5

Output: 225

Formula: 1

Input: n = 7

Input: 784

Formula: 1

Example

# Define the function for the sum of cubes
def sumOfSeries(n): 
    sum = 0
    for i in range(1, n+1): 
        sum += i*i*i 

    return sum

# Call the function
n = 5
print(sumOfSeries(n))

The output of the above example is:

225

Python3 Examples

❮ Python String Rindex Ref Math Frexp ❯