def isqrt_newton

bend-collections-laws-crypto@1.0.0.0 · src/math/w64.bend:492

import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as W64
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W

492# floor(sqrt(n)) from any estimate r1: down while r^2 > n, then up while
493# (r + 1)^2 <= n; the fuel covers any estimate
494def isqrt_newton(+n: W.U64, +r1: U32) -> U32:
495  isqrt64_fix(n, down64(1n+U32.to_nat(r1), n, r1, sq_over(n, r1)))

Uses (7)

Used by (1)