+ 1
What wrong with code?
n=int(input('n:')) #1*n+2*(n-1) k=1 while k>n: sum(k*n) k+=1 n-=1 print(sum)
4 odpowiedzi
+ 1
Ohh... just replace the line sum=k*n with sum=sum+k*n
It will sum over all terms.
+ 1
n=int(input('n:'))
#1*n+2*(n-1)
k=1
sum=0
while k<n:
sum=k*n
k+=1
n-=1
print(sum)
I think this is the right code.
+ 1
I'm needed to calculate sum of these 1*n+2*(n-1).... While n not be a > first factor
0
There is no function called "sum".