the-honk/school/royal institute/from ancient babylon to quantum computing/babylonian square root.java
2021-12-21 19:46:28 +00:00

18 lines
346 B
Java

import java.util.Scanner;
public class Babylonian
{
public static void main(String [] args)
{
Scanner input = new Scanner(System.in);
long x = input.nextLong();
double a = 2;
while (Math.abs(a - (x / a)) > 1)
{
a = (a + (x / a)) / 2;
}
System.out.println(a);
}
}