Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (require test-engine/racket-tests)
- (define (zminus x y) (+ x (- y)))
- (define (zmul x y)
- (zmulh x y x))
- ;; (zmulh x y z) returns (y-1) * z + x, for any non-negative number y
- (define (zmulh x y z)
- (if (< y 2)
- (if
- (= y 0)
- 0
- x)
- (zmulh (+ x z) (zminus y 1) z)))
- (define (zmuln x y)
- (if (> y -1)
- (zmul x y)
- (- (zmul x (- y)))))
- (define (zdivizion x y)
- (zdivh x y 1 y))
- (define (zdivh x y z h)
- (if (= x y)
- z
- (zdivh x (+ y h) (+ 1 z) h)))
- (test)
Add Comment
Please, Sign In to add comment