I am trying to make a program that will sum the cube of a number up to an upper boundary.
The mathematical formula is (n*(n+1)/2)^2
My code in Python:
def cube_numbers():
upper_boundary = 0
cube_sum = 0
upper_boundary = input("Please enter the upper boundary:")
cube_sum = ((upper_boundary * (upper_boundary + 1) / 2)**2)
print("The sum of the cube of numbers up to" & upper_boundary & "is" & cube_sum)
#main
cube_numbers()
But I get the following error:
Traceback (most recent call last):
File "C:/Users/barki/Desktop/sum of cubes.py", line 10, in <module>
cube_numbers()
File "C:/Users/barki/Desktop/sum of cubes.py", line 5, in cube_numbers
cube_sum = ((upper_boundary * (upper_boundary + 1) / 2)**2)
TypeError: can only concatenate str (not "int") to str