Write a while loop that calculates the sum of the cubes of numbers starting from 1 to 40 (inclusive). That is, the loop prints the foloowing value 1 + 23 +33 + ... +403. Make sure to define any variables you may need.
s = 0
n = 1
while n <= 40:
s += n**3
n += 1
print(s)
Comments
Leave a comment