lunduniversity / schoolprog

Programming exercises for primary and secondary education, in Swedish.
https://lunduniversity.github.io/schoolprog/
15 stars 6 forks source link

Create exercise with gcd #22

Open exoji2e opened 6 years ago

exoji2e commented 6 years ago

Görel wants an exercise where a function for calculating gcd is created. This will be used in a turtle graphics exercise.

I guess we need a small description + proof for Euclid's algorithm, and a little bit of boilerplate code for an iterative solution.

Maybe the exercise can include some fractional numbers that needs to be reduced as well.

gorelhedin commented 6 years ago

@ahnlabb I use gcd in the Piece-of-Cake exercise, see https://lunduniversity.github.io/schoolprog/exercises/piece-of-cake/, but in a way that is independent of a dedicated gcd exercise - I simply give them some code for gcd. It would still be good with a separate gcd exercise that focuses on them understanding how and why gcd works, and perhaps exploring different algorithms for computing it.