Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
I would say you don't need another function. Theoretically this should work: gcd(1, gcd(2,3))
14th May 2022, 5:14 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Sure :) You just need to convince yourself of the recursive step gcd(ds(1..n)) = gcd(d(1), gcd(ds(2..n)) for a sequence of positive integers d(1), ..., d(n), where by ds(i..j) I mean d(i), ..., d(j). This is a recursion over the length of the sequence. The base case being gcd(d) = d
15th May 2022, 5:40 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
14th May 2022, 5:28 PM
Denise Roßberg
Denise Roßberg - avatar
0
Wonderful task to practise recursion :)
14th May 2022, 6:04 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
Yes, it would :)
15th May 2022, 2:23 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar