https://github.com/tahmidefaz/no-sqrt
Estimates the square root of a number without the sqrt() function
https://github.com/tahmidefaz/no-sqrt
algorithm binary-search python python3 square-root-estimate
Last synced: 9 months ago
JSON representation
Estimates the square root of a number without the sqrt() function
- Host: GitHub
- URL: https://github.com/tahmidefaz/no-sqrt
- Owner: tahmidefaz
- License: mit
- Created: 2017-09-03T03:13:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T19:23:22.000Z (about 8 years ago)
- Last Synced: 2025-01-16T12:35:35.296Z (11 months ago)
- Topics: algorithm, binary-search, python, python3, square-root-estimate
- Language: Python
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# no-sqrt
Estimates the square root of a number without the sqrt() function.
Uses binary search algorithm to find the root of a number.
## Explanation
### We know that:
`if sqrt(x) = z, then x = z^2`
So, `if given x`, we need to find a number between 0 and x whose square is equal to x.
To find a z whose square is equal to x, the program uses binary search.
Time complexity: **bigO = O(log n)**