diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-07-13 06:28:23 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-07-13 06:28:23 +0000 |
commit | 183d208551abe4fefc0ca944615dab89c8acc40f (patch) | |
tree | 581dec0b21c3ca39fc34182b1401e8b1a82a258e /games | |
parent | 049e4dc95e568f90eaae5e481cb4c9172578065f (diff) |
Integer square root and perfect square test
This adds an implementation of the integer square root using a variant
of Newton's method with adaptive precision. The implementation is based
on a pure Python description of cpython's math.isqrt(). This algorithm
is proven to be correct with a tricky but very neat loop invariant:
https://github.com/mdickinson/snippets/blob/master/proofs/isqrt/src/isqrt.lean
Using this algorithm instead of Newton method, implement Algorithm 1.7.3
(square test) from H. Cohen, "A course in computational algebraic number
theory" to detect perfect squares.
ok jsing
Diffstat (limited to 'games')
0 files changed, 0 insertions, 0 deletions