Write a LISP function named makeeven that makes an odd numbe

Write a LISP function named make-even that makes an odd number even by adding one to it. If the number is already even, it should return the number.

Solution

LISP program to find an even number and make it odd by adding 1 to it is given below :-

;make even
(defun make-even (n)
(if (oddp n) ; the test
      (+ 1 n) ;the true statement
    n)) ; the false statement

 Write a LISP function named make-even that makes an odd number even by adding one to it. If the number is already even, it should return the number.SolutionLIS

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site