

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for implementing the euclidean algorithm, which is used to compute the greatest common divisor (gcd) of two integers, using recursion in c#. It includes a historical background of the algorithm and a step-by-step guide for creating a console application.
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Historical Significance: Euclidean Algorithm is one of the oldest algorithms – at least 300 BCE in Ancient Greece. The Euclidean Algorithm is contains one of the “most famous” recursion functions and is used to compute the greatest common divider (GCD) of any two integers. It is extremely popular because it does not require any factoring. (For more information: http://en.wikipedia.org/wiki/Euclidean_algorithm). How GCD work: Given two integers (let’s call them x and y. Both x and y are not equal to zero). If y is equal to 0, then x is the GCD. Otherwise, repetitively do through the process using y and the remainder of dividing x by y (commonly referred to as: x mod y). Normally, the definition is written in the following format: Writing the Program: Today, we are going to write a C# console application (using recursion) to implement the above algorithm. (Note: This algorithm can be written iteratively, but we will be focusing on recursion).
Challenge Question: Can you write the gcd method from RecursionGCD as only one line of code?