Euclidean algorithm, recursion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Euclidean algorithm, recursion

So this is my try to implement Euclidean algorithm. I don't understand why it's returning None on last iteration https://code.sololearn.com/c2g3Zu9Lx0eD/?ref=app

7th Sep 2022, 9:55 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar
5 Answers
+ 3
Thanks Ę ~ J It helped. So basically i just had to add return to function call in else statement
7th Sep 2022, 10:51 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar
+ 1
Ę ~ J still returning None without this line
7th Sep 2022, 10:04 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar
+ 1
Ę ~ J if i call the the function without print() then there will be no output as well
7th Sep 2022, 10:07 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar
+ 1
Ę ~ J this algorithm must return 80 at the end, last iteration don't work i don't know why
7th Sep 2022, 10:10 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar
+ 1
Ę ~ J Last call of function will be like this eucl(160, 80) In this case the if statement is matched, and must return 80, but it's returning None
7th Sep 2022, 10:15 AM
Sator Arepo🌾🌌
Sator Arepo🌾🌌 - avatar