+ 5

Challenge

Raise a number to the square using only: - While or for - Operators + - (NOT MULTIPLICATION *) Terms * Do not use modules or libraries that give the value squared * You can use the language you want ;)

10th Dec 2017, 7:38 PM
The Rab-bit
The Rab-bit - avatar
14 Respostas
12th Dec 2017, 5:59 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 11
https://code.sololearn.com/c522HM1YsqQC/?ref=app
15th Dec 2017, 6:28 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 6
Nice challenge
10th Dec 2017, 9:09 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 6
Not working with decimal numbers yet, but with integers is ok. https://code.sololearn.com/cz16O6j32Oho/?ref=app
10th Dec 2017, 9:56 PM
Marfik Em
Marfik Em - avatar
+ 4
https://code.sololearn.com/cuP03Nb6newm/?ref=app
10th Dec 2017, 8:46 PM
LunarCoffee
LunarCoffee - avatar
10th Dec 2017, 8:16 PM
MuzzRK
MuzzRK - avatar
+ 2
Updated a^n power function for any(1<=n) degrees of integers (negative int.s too) https://code.sololearn.com/cIl5A4JQFLTa/?ref=app
11th Dec 2017, 3:37 PM
abdulazizumarovich
abdulazizumarovich - avatar
+ 2
Hi. Here is my code in python. It work for negative numbers too. https://code.sololearn.com/cpX0YpB7nJnc/?ref=app
25th Aug 2019, 8:27 AM
Benjamin Alejandro Luna
Benjamin Alejandro Luna - avatar
+ 1
@HeisAbdulaziz your code doesn't work with negative numbers if you want to raise them to even power. in example (-3)^2
11th Dec 2017, 3:47 PM
MuzzRK
MuzzRK - avatar
+ 1
as i've tagged ))) // a^n=1*a*a*a*a...*a // input: a n (a>0,n>0 a,n=int) // output: a^n but it isn't pow i have some bugs
11th Dec 2017, 3:56 PM
abdulazizumarovich
abdulazizumarovich - avatar
+ 1
oh sorry, I'm probably just blind haha
11th Dec 2017, 3:58 PM
MuzzRK
MuzzRK - avatar
+ 1
Using sum of first n odd integers to give the square of n: https://code.sololearn.com/cUKbPSDr4iTi/?ref=app
24th Sep 2021, 6:43 AM
Steve
Steve - avatar
+ 1
''' Challenge Raise a number to the square using only: - While or for - Operators + - (NOT MULTIPLICATION *) Terms * Do not use modules or libraries that give the value squared * You can use the language you want ; ''' number=int(input());result=0 for i in range (number): result+=number print('The square of',number,'is',result)
12th Dec 2022, 12:23 PM
Haresh Kumar Gupta
Haresh Kumar Gupta - avatar
0
It does not look like it been solved for decimals yet. You could make a larger challenge if complex numbers were included!
2nd Sep 2022, 11:10 AM
dan
dan - avatar