Whenever the second number(y in this case) is a negative the code does not give me an answer and eventually crashes. So `(RecursiveMultiply 9 3)`

works, `(RecursiveMultiply -9 3)`

works, `(RecursiveMultiply 9 -3)`

crashes, `(RecursiveMultiply -9 -3)`

crashes.

This is the code I have

```
(define RecursiveMultiply
(lambda (x y)
(if (= y 1)
x
(+ x (RecursiveMultiply x (- y 1))))))
```

Your procedure goes on forever if y is negative, you can fix this by changing your

`if`

to a`cond`

that has a condition with different code to accommodate a negative number if y is indeed negative.The part that has the problem,

`(if (= y 1) x (+ x (RecursiveMultiply x(- y 1))))`

Is basically sayingif y is 1, return x. If y is not 1, execute the procedure again after decrementing y.Your problem is that if y is negative or zero, it is already less than 1. Subtracting 1 from a negative number/zero only pushes y further and further away from 1, and you will never actually reach 1. Your procedure is stuck in an infinite loop and crashes the interpreter.Here's how you fix the problem:

I would also like to point out that your procedure is slow, it runs O(n), which means that the time/space needed to run the procedure grows linearly as the input grows, which is very bad when dealing with large numbers. I would recommend making this an iterative function instead to make it run O(log n), a much faster function.

Here is an example of an iterative multiplication procedure I wrote that runs O(n) worst case and O(log n) best case:

Try to recreate this but with your procedure.