+ 2
how to fix loop for Square Numbers?
prints 2 ^ 2 = 9 i know sound's crazy but please check the code 👀 https://code.sololearn.com/c5CzsSp8enpf/?ref=app
6 Respuestas
+ 3
thank you John Wells i appreciate your assistance 🙏
+ 2
n = 2
n3 = 3**2 = n**2 + (n + n + 1) = 2**2 + (2 + 2 +1) = 4 + 5 = 9
+ 2
thanks john but the real problem at output it prints 3**2 ==16
+ 2
Because you are using 3 to calculate 3 instead of 2 to calculate 3. Add the n+1 to the print because it belongs there
+ 2
Everyone of these has n+1 = target square
n = 2
n3 = 3**2 = n**2 + (n + n + 1)
n = 3
n4 = 4**2 = n3 + (n + n + 1)
n = 4
n5 = 5**2 = n4 + (n + n + 1)
+ 1
n =
***
***
***
=
++o
**+
**+
= (n-1) ^2 ->*
+ 2(n-1) -> +
+1 -> o
But instead of n-1 u used n.