For the last problem of A2, we have to prove if m >= n, then gcd(m,n) = gcd(n, m-n). I got stuck at first until being inspired by the project of CSC148.
For CSC148, we wrote bunch of methods such as __less_equal__(self, s2), and __equal__(self, s2). For __equal__, the comment says we can just use __less_equal__ by saying (self <= s2 and s2 <= self). That's smart and tricky then I realized a = b is equivalent to a<= b and b <= a.
Based on what I found above, instead of proving the equation directly, which I found impossible, I can prove it indirectly by proving gcd(m,n) >= gcd(n, m-n) and gcd(m,n) <= gcd(n, m-n).
Here are the steps. Hope that make sense.

Good job on the proof, it definitely looks like the right approach! Don't forget that you can't post answers to questions before the assignment is due though! (It appears you posted this March 5, and the assignment was due March 6).
ReplyDeleteOh, I was aware of that. It was in draft before Mar.8. Mar.5 was just the date I started writing not publishing.
ReplyDelete