Solved

GCD of two numbers in LISP

Posted on 2004-04-24
3
3,263 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
Comment Utility
(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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now