Skip to content

Commit

Permalink
add another algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
daedalus committed Sep 5, 2023
1 parent 69c0f68 commit f7a424a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sqrttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ def sqrt(x):
return r


def sqrt(n):
x = n
y = 1
e = 0.00000001
while (x - y) > e:
x = (x + y) / 2
y = n / x
return x

# given the x**2-2=0 condition we bruteforce an aproximation to sqrt(2)


Expand Down

0 comments on commit f7a424a

Please sign in to comment.