Use quotient/remainder in bezout
Use quotient/remainder in bezout. This is much more efficient.
This commit is contained in:
parent
cc643e4c50
commit
6b5e4c90e4
|
@ -37,8 +37,7 @@
|
|||
(define (bezout-binary a b)
|
||||
(: loop : Integer Integer Integer Integer Integer Integer -> (List Integer Integer))
|
||||
(define (loop a b ua va ub vb) ; a>=b>0 , a = ua*a+ub*b, b = ub*a+ub*b
|
||||
(let ([r (remainder a b)]
|
||||
[q (quotient a b)])
|
||||
(let-values ([(q r) (quotient/remainder a b)])
|
||||
(if (= r 0)
|
||||
(list ub vb)
|
||||
(loop b r ub vb (- ua (* q ub)) (- va (* q vb))))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user