the-honk/coursework/royal institute computer science masterclass 2021/from ancient babylon to quantum computing/babylonian square root.java
2024-10-09 18:02:29 +01: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);
}
}