Another optimisation possible if N is odd, is to step back by 2 each time.And if N is even, factor out all the powers of 2, and run the algorithm against the remaining factor. For example,
which leaves1000 == 2**3 * 5**3
leading to125 == 5**3
as "close enough".5 * 2**2 == 20
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re^4: OT: Finding Factor Closest To Square Root
by QM
in thread OT: Finding Factor Closest To Square Root
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |