0

wrtire a program for cube of first n natural number, what problem with my logic

n=int(input("Enter an integer=")) sum=0 for i in range(1+n+1): sum=sum+(i*i*i) print("sum=",sum)

19th Sep 2021, 1:15 AM
Abhishek Kumar
Abhishek Kumar - avatar
2 Respostas
+ 2
Hi Abhishek! You have to separate function parameters using "," not "+". I mean your range function needs to be like this, for i in range(1,n+1): A cube number is a number multiplied by itself 3 times.
19th Sep 2021, 1:31 AM
Python Learner
Python Learner - avatar
0
What does the question want you to do with those "cubes" ?
19th Sep 2021, 1:23 AM
Arsenic
Arsenic - avatar