Hello everyone! Now we have a new quiz, and we’re supposed to create a program that calculates the greatest common divisor of two integers… pretty easy hahaha
We’re going to ask the user to give those values (obviously integers because… I don’t know, integers rules!) and the program will calculate the greatest common divisor using the Euclid’s algorithm. Now what the… is the Euclid’s algorithm?? Here you can see what it is…
Now let’s create the program. The function called MasterAguayo is where the magic happens. It takes two values and by using ‘if statements’ we are switching the numbers using modules and all that stuff.
It is pretty easy to understand this algorithm and you’re supposed to know how it works if you’re at college… if that’s not the case, well don’t worry because there is a lot of information available on the web.
Here is my code via GitHub. You can check it out and feel free to do whatever you want with it.
Alex H.
Quiz #6 by alexhfoo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.