I am working on a homework problem that asks me to prove that two different methods of finding the greatest common denominator work. One of them is clear that it works. The other it seems to me does not work. I even went so far as to write a java program to check this out. Can someone give this a glance and tell me if I am mistaken or not please?
It seems to me that no matter what this program will always end up in a divide by 0 situation. Take two easy numbers: 21 and 7. We can glance at this and say the greatest common divisor is 7. However, the program does 21 mod 7 which yields 0. Then next loop 7 mod 0 which is a divide by 0.
Pseudocode:
It seems to me that no matter what this program will always end up in a divide by 0 situation. Take two easy numbers: 21 and 7. We can glance at this and say the greatest common divisor is 7. However, the program does 21 mod 7 which yields 0. Then next loop 7 mod 0 which is a divide by 0.
Pseudocode: