0
Write a program to find squre root ?
Without using sqrt() in python
7 odpowiedzi
+ 6
A root of a number is just x**(1÷2), where x is the number you want to find the square root of, so using that would return the same thing as sqrt(x)
+ 6
C, C++ do have a function called pow defined in the math library.
For others you can write an exp function to do the same. Exponentiation being iterated multiplication. 2^3 = 2*2*2
For (n^m) Using a for loop which runs m times and multiplies n by a result variable(r=1).
#Demo code in ruby
https://code.sololearn.com/cMxG18sTH9wb/?ref=app
+ 5
Here is a tutorial which explains newton's method:
https://youtu.be/2158QbsunA8
+ 4
Werg Serium I don't know, but he can ask us if not.
I think Faisals method is much easier ;)
0
Denise the question is, can he put the newton's method into code?
0
Yes it is Denise. The Faisal method is the simplest ones. No need of hard maths xD
0
But this is only possible because in python there is an exponential operator **. If you try java, c or c++, there is no way if you did not use newton's method.