Calculate square without using sqrt | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Calculate square without using sqrt

31st Jul 2022, 4:47 PM
Sanket Suresh Sonawane
2 ответов
+ 3
Please tag the relevant programming language. You can use exponent 0.5 to get the square root. edit: And please clarify if you calculate the square or the square root.
31st Jul 2022, 6:02 PM
Lisa
Lisa - avatar
0
You should not use sqrt to calculate the square of a number because sqrt calculates square root. To calculate the square, simply multiply the number by itself. n = 5; nsquared = n*n; // = 25
31st Jul 2022, 10:55 PM
Brian
Brian - avatar