the-honk/royal institute computer science masterclass 2021/from ancient babylon to quantum computing/babylonian square root.py

8 lines
148 B
Python
Raw Normal View History

2024-10-09 17:02:29 +00:00
x = float(input('Please input the number to calculate the square root of! '))
a = 2
while abs((a - (x / a))) > 1:
a = (a + (x / a)) / 2
print(a)