summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-07-13 06:28:23 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-07-13 06:28:23 +0000
commit183d208551abe4fefc0ca944615dab89c8acc40f (patch)
tree581dec0b21c3ca39fc34182b1401e8b1a82a258e /games
parent049e4dc95e568f90eaae5e481cb4c9172578065f (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