Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

I want to create a program that calculates the square root of a number without using Math.sqrt

1 Answer

0 votes
by (13.1k points)

You can do something like this:

public static void calcRoot(){

    double num=9;

    double guess=0;

    double result=6;

    while(Math.abs(guess-result)!=0){

        guess=result;

        result=(guess+(num/guess))/2;       

    }

System.out.print(result);

}

Want to learn Java? check out the java certification from Intellipaat.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...