If you think that a divisor for a number n1 cannot be greater than n1 / 2, you might attempt to improve the program using the following loop:
k = 2
while k <= and k <= :
if n1 % k == 0 and n2 % k == 0:
gcd = k
k += 1
This revision is wrong. Can you find the reason?
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.