[Community Puzzle] Euclid's Algorithm

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Darkrentin,validated by @Hawat_MH,@Antsurf and @VilBoub.
If you have any issues, feel free to ping them.

1 Like

Euclid would’ve made a decent programmer :slight_smile:

hello. for example gct(21,3) my outcome is:
21=3 7+0 (3 multiplicate 7)
3=0
3+0 ( 0 mult.3)
GCD(21,3)=3
is wrong.
is something wrong with format, or can you give me a hint please, what is wrong here.thank you

The answer for 21 & 3 as input should be:

21=3*7+0
GCD(21,3)=3

You can’t have a calculation line multiplying 0 by something. You have to stop when a calculation line give you a remaining value of 0, like here : 21=3*7+0 (3 multiplicate 7)

This was actually really cool to work on, and it took a moment for my mind to understand what was being asked even after reading through the requirements. The first fvt after submitting the code helped me realize a mistake in my understanding. Well done on this, and thanks!

Had it solved and only then noticed the “recursive” label on the puzzle.
Used a basic loop instead, which somehow seemed more in line with the textual description of the algorithm (repeat until).
Still a neat easy puzzle!