the-honk/python/calculators/sqrt.py

8 lines
107 B
Python
Raw Normal View History

2021-07-10 11:23:46 +00:00
def sqrt(x):
a = 2
while abs((a - (x / a))) > 1:
a = (a + (x / a)) / 2
2021-07-16 16:25:04 +00:00
return int(a)
2021-07-10 11:23:46 +00:00
print(sqrt(81))