Hey guys. Im new to these forums and was hoping i could get some help. Trying to figure out how to divide a number by another number in scheme without using /. I have written these functions that i can use in creating the divide function:
(define pwr (lambda (a b) (if (= b 0) 1 (* a(pwr a(- b 1)))))) (define (add c d) (if (= d 0) c (add (+ c 1) (- d 1)))) (define (subt e f) (if (= f 0) e (subt (- e 1) (- f 1)))) (define (multi g h) (if (= h 0) 0 (add g(multi g(- h 1)))))
It is supposed to be done like how the multi function above was done. (by using add in this case). I am thinking there is some way to do it by using multi, but i cant figure it out : /
Any help appreciated!