+ 1

Square root of N

Guys, I wrote a code, about getting the square root of any non negative number. But I am always getting close answers. I don't know if it's the only way or not. I don't want to copy other's codes. If I wanted I could have examined other's codes, but I wanted to know if you could fix my code without any dramatic changes.

28th Jun 2018, 8:46 AM
Armen
Armen - avatar
10 Answers
+ 3
Thnx, Kinshuk Vasisht. 👍
28th Jun 2018, 9:02 AM
Armen
Armen - avatar
+ 3
Thnx again.
28th Jun 2018, 9:08 AM
Armen
Armen - avatar
+ 2
You can try using taylor series to calculate more precise square roots. https://www.sololearn.com/discuss/292240/?ref=app The math remains the same.
28th Jun 2018, 8:55 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
You can read the formula from here : https://www.mathsisfun.com/algebra/taylor-series.html The derivative of √x is 1/(2√x)
28th Jun 2018, 8:59 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
Here is a better process, without derivatives : burningmath.blogspot.com/2013/12/finding-square-roots-of-numbers-that.html?m=1
28th Jun 2018, 9:06 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
Jay Mathews, It's a nice code. But I'm interested in making the code without using any mathematical functions.
28th Jun 2018, 9:51 AM
Armen
Armen - avatar
+ 2
Thnx, hinanawi.
28th Jun 2018, 9:59 AM
Armen
Armen - avatar
28th Jun 2018, 8:46 AM
Armen
Armen - avatar
+ 1
Sadly, I don't know about Taylor series.
28th Jun 2018, 8:57 AM
Armen
Armen - avatar
+ 1
you can always use the newton method: https://en.m.wikipedia.org/wiki/Newton%27s_method
28th Jun 2018, 9:58 AM
hinanawi
hinanawi - avatar