Calculation of the Formula:
The following Python code demonstrates how to calculate the sum of cubes of the first numbers, following the formula:
Requirement:
Input:
Output: 225
Formula:
Input:
Output: 784
Formula:
Example
# Function to calculate the sum of cubes def sumOfSeries(n): total_sum = 0 for i in range(1, n + 1): total_sum += i * i * i # Cube of the current number return total_sum # Call the function n = 5 print(sumOfSeries(n))
Output
225
In this code, the function sumOfSeries(n)
iterates from 1 to , calculates the cube of each number, and accumulates the sum. For , the result is 225. Similarly, for , it will return 784.