Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;extended euclid algorithm
- (define (solve-ax+by=1 a b)
- (euclid1 a b (floor (/ a b)) (modulo a b) 1 0 0 1))
- (define (euclid1 dividend divisor quot rem x y x1 y1)
- ;; What is the invalid case?
- (cond ((not (= (gcd dividend divisor) 1)) (display "no solution orz"))
- ((= rem 0) (cons x1 y1))
- (else (euclid1 divisor rem (floor (/ divisor rem)) (modulo divisor rem) x1 y1 (- x (* quot x1)) (- y (* quot y1))))))
Advertisement
Add Comment
Please, Sign In to add comment