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; } }
find square root
猜你喜欢
转载自www.cnblogs.com/sea-stream/p/12013100.html
今日推荐
周排行