+ 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.

10 Answers

+ 3

Thnx, Kinshuk Vasisht. 👍

+ 3

Thnx again.

+ 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.

+ 2

You can read the formula from here : https://www.mathsisfun.com/algebra/taylor-series.html
The derivative of √x is 1/(2√x)

+ 2

Here is a better process, without derivatives : burningmath.blogspot.com/2013/12/finding-square-roots-of-numbers-that.html?m=1

+ 2

Jay Mathews, It's a nice code. But I'm interested in making the code without using any mathematical functions.

+ 2

Thnx, hinanawi.

+ 1

Here's my code https://code.sololearn.com/c5X3RnMAOx8q/?ref=app

+ 1

Sadly, I don't know about Taylor series.

+ 1

you can always use the newton method:
https://en.m.wikipedia.org/wiki/Newton%27s_method

Hot today

What is indentations... ?

6 Votes

Application RAM usage

1 Votes

Showing errors!

2 Votes

About Java McQ

0 Votes

Q. Anna is 18 years old

-2 Votes

int num = 2;
int x = 3;
if(num >= 2) {
if(x > 4) { num = 3; }
else { num = 4; }
}
else {x = 1; }

1 Votes

Balconies Problem in C

0 Votes