Python experiment (3)

According to the formula s=12+22+32+…+n2, find the cumulative sum. The maximum number of items n where s does not exceed 1000, the program running result is as follows:

x=1
count=0
print("x"+"----> "+"sum")
for x in range(0,14):
  count+=x*x
  
  print(str(x)+" -----> "+str(count) )
  
print("sum"+" --->  "+str(count))

Here is the quote

Guess you like

Origin blog.csdn.net/weixin_45803282/article/details/110711689