Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m supposed to write a function (in this case, it is multiples) that gets a na

ID: 3639733 • Letter: I

Question

I'm supposed to write a function (in this case, it is multiples) that gets a natural number and returns the sum of all numbers from 0 to num (inclusive) that are multiples of 3 or 5.

My problem is that my program successfully determines if a number is a multiple of 3 or 5, but once it accomplishes that, the program terminates. It is supposed to go all the way down to 0. Can you guys help me out? Here are the functions ive defined. Divide works perfectly, its multiples that is bugged.

(defun divides(num j)
(if(= num 0)
1
(if(< num 0)
0
(divides (+ num (* -1 j)) j))))






defun multiples (num)

(if(= num -1)
NIL

(if(=(divides num 3) 1)
(setq y num)


(if(=(divides num 5) 1)
(setq x num)
(multiples (+ num -1)
)))) )

If I input (multiples 8), it decrements down to 5, then terminates (I know why), I cant figure out how to get it to keep looping even when it finds one multiple. What code is missing?

Explanation / Answer

Hi! Cramster Terms & Conditions were changed recently (I hope you have read them). Now, experts have to send the answers to askers' inbox after you rate them. That is because of people copying from older threads which have public answers. Hence we can only send the answer after you rate. So please give me a Lifesaver rating and I'll send the solution to your inbox or e-mail. You've got no other option to get the answer, because no one can give you the answer over here. Even you might be banned for rating a user that gave the answer directly on your question. You need not worry as I have the solution ready in my notebook. Hope you rate me :)