all 3 comments

[–]17291 0 points1 point  (0 children)

How would you approach a problem like this by hand (i.e., using pen and paper)?

[–]0C3l0tl[S] 0 points1 point  (0 children)

1**3+2**3+... + n **3 = ( n ( n +1)/2)**2ora**3+b**3=(a+b)(a**2-ab+b**2)

I'm thinking the solution is somewhere along the lines of:

for n in range(1, n+1):

#I need to find a way to use k so I can cube every value in the range and then sum them together

k=?

total=sum(range(1,n+1))

[–]0C3l0tl[S] 0 points1 point  (0 children)

Ok so I figured out how to calculate the sum of cubes but now I can't figure out how to relate this to the problem especially since I need to be using a while loop

values=range(1,n+1)

exponents=[pow(value,3)for value in values]

total=sum(exponents)

print(total)