I started learning Python, I encountered the following problem.
The conditions of the problem are as follows:
For this natural
ncalculate the sum of1Β²+2Β²+3Β²+...+nΒ².
I got this code, but it does not display the correct values. What could be the error? You need to use only while , without using for / range :
n = int(input()) i = 0 sum = 0 while i < n: i = (i + 1)**2 sum = i + n**2 print(sum)
if i < n: continue if ii == n ΠΏΠ΅ΡΠ΅Π΄ print, otherwise the answer will be a sample of numbers - user340699