Solved

GCD of two numbers in LISP

Posted on 2004-04-24
3
3,425 Views
Last Modified: 2013-12-26
How to write a program in LISP to find the GCD of two numbers.
0
Comment
Question by:rmvprasad
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 40 total points
ID: 10912579
(defun gcd (a b)
    (label ((_gcd (lambda (a b)
        (cond ((zerop b) a)
            ((lessp a b) (_gcd a (remainder b a)))
            (t (_gcd b (remainder a b)))))))
    (_gcd (natural (abs a)) (natural (abs b)))))
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question