Please use a for while for this one For python please Sum of

Please use a for while for this one.

For python please.

Sum of cubes Write a program that finds the sum of the cubes of the first n natural numbers. Test code:

Solution

// def sum_of_cubes(n): return sum(i**3 for i in range(1,n+1)) def main(): number = int(raw_input(\" sum of cubes for?\")) #this doesn\'t do anything but change n to 0 #for i in range(num): # n = n - 1 print \"The result of the sums is:\", sum_of_cubes(num) main()
Please use a for while for this one. For python please. Sum of cubes Write a program that finds the sum of the cubes of the first n natural numbers. Test code:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site