Ask Question
17 December, 03:25

Design a recursive version of the Euclidean algorithm

+4
Answers (1)
  1. 17 December, 03:29
    0
    Here's a recursive Python program that finds the greatest common denominator:

    #!/usr/bin/python

    import sys

    def gcdR (x, y):

    if (y):

    return (gcdR (y, x % y))

    return x

    if (__name__ = = "__main__"):

    x = max (int (sys. argv[ 1 ]), int (sys. argv[ 2 ]))

    y = min (int (sys. argv[ 1 ]), int (sys. argv[ 2 ]))

    print gcdR (y, x % y)

    sys. exit (0)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Design a recursive version of the Euclidean algorithm ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers