Euclidean Algoritmh | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 5

Euclidean Algoritmh

With this code you can find the largest common divisor of two numbers. This code was made and inspired by the Euclidean Algorithm, I hope you enjoy it, and will like to read what you think. https://code.sololearn.com/c4mBLbUzDPPD/?ref=app

18th Aug 2017, 3:10 AM
Fabian Nieves
Fabian Nieves - avatar
8 Réponses
+ 6
thanks bro!
18th Aug 2017, 8:44 PM
Fabian Nieves
Fabian Nieves - avatar
+ 6
yes I will 😋
23rd Aug 2017, 3:38 AM
Fabian Nieves
Fabian Nieves - avatar
+ 3
Woo is very true. I did not take that into account. Thanks for reporting the flaw. I'll fix it
24th Aug 2017, 12:40 AM
Fabian Nieves
Fabian Nieves - avatar
+ 1
Nice, I recently saw this algorithm :)
18th Aug 2017, 4:51 AM
Oscar Albornoz
Oscar Albornoz - avatar
+ 1
I just posted under My Codes Euclid's Algorithm in Java if you want to give it a look. 😀
23rd Aug 2017, 3:28 AM
Matt P. * Code Bender *
Matt P. * Code Bender * - avatar
0
i started a design and analysis of algorithms course this is the first algo we looked at Hahah 💻✌
23rd Aug 2017, 2:41 AM
Matt P. * Code Bender *
Matt P. * Code Bender * - avatar
0
Hi. Sorry, your program is nice but it has a bug. For example if num1 = 170 and num2 = 85 then there is no output, if num1 = 45 and num2 = 72 the output is 18 instead of 9 and if num1 = 92 and num2 = 56 the output is 8 instead of 4. This is definitely not correct. The bug is in your method: you always use num2 as dividend, but in euclidean algorithm the dividend always change every step like this: num_1 = r_0 * q_1 + r_1, with num_2 = r_0 r_0 = r_1 * q_2 + r_2 r_1 = r_2 * q_3 + r_3 ... r_n-1 = r_n * q_n+1 + 0 Then mcd = r_n I hope it helps.
23rd Aug 2017, 11:47 PM
Martin Carl
Martin Carl - avatar
0
Hi. Did you change the code because the errors i described earlier occur: 92 and 56 -> no ouput, 45 and 72 -> 18 instead of 9 and 92 and 56 -> 8 instead of 4. Sorry.
19th Sep 2017, 4:06 PM
Martin Carl
Martin Carl - avatar