0
What am I doing wrong ?
The function cubicSeries takes an integer n and add the sequence of numbers which are cubed from the beginning to the integer. If n is less than or equal to 0 then the function must return 0. A while loop must be used in this function. The cube of the input n MUST be inclusive in the sum https://code.sololearn.com/crrA1GJgsJg3/?ref=app
3 Antworten
+ 1
Triz you should use a while loop.
(not a "hidden" for loop 😉)
def cubicSeries(n):
if n <= 0:
return 0
else:
total = 0
while n>0:
total= total + n**3
n= n-1
return total
print(cubicSeries(6))
+ 1
Coding Cat Thank you!
+ 1
Triz you're welcome.