Pysquare-Finder
finds the square root of an specific number using vanilla python
Calculations
To get the square root of a not exact number you need to do:
(X + Y) / √(Y) * 2
Example:
To get the square root of √(634): <- not exact
- get the radicand of √(634), add the radicand of the closest exact square root (625)
- divide by the square root of the closest exact square root and multiply by two
You should have something like:
634 + 625
--------- = 25.18
25 * 2
Note
The code isnt 100% clean! It have a specific bug that:
- really close square numbers are automatically rounded, e.g: square of 15 shows as 4.0, but in reality it is 3.87
How it works
Exact Square Roots
- first uses a
for
loop in range of 1 to the specified number. - checks if one of the checked values on the loop multiplied by himself is the specified value
- if it is, just tell you!
Not Exact Square Roots
- first subtracts the n.e square roots with the range of the amount to be checked
- if in the range that you specified in bforce has a exact square root, pick the closest exact square root
- re-verify if its really an exact square root
- if it is, do the calcs