public class Solution {
    public static void main(String[] args) {
        Scanner ip = new Scanner(System.in);
        System.out.print("Enter a number: ");
        double n = ip.nextDouble();
        System.out.println(sqrt(n));
        ip.close();
    }

    public static double sqrt(double number) {
        double t;

        double squareRoot = number / 2;

        do {
            t = squareRoot;
            squareRoot = (t + (number / t)) / 2;
        } while ((t - squareRoot) != 0);

        return squareRoot;
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-12-08
  • 2021-09-09
  • 2021-08-21
  • 2021-08-02
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-02
  • 2021-06-13
  • 2022-12-23
  • 2022-02-13
  • 2021-12-28
  • 2021-10-27
  • 2021-10-15
相关资源
相似解决方案