Monday 27 October 2014

GCD induction proof

I apologize if this is a duplicate question (believe me, I've searched). This question is a part of an ungraded class warm-up exercise.



Question:
Using induction, prove that for all positive integers $x$ and $y$, that $g(x,y)$ computes the GCD of $x$ and $y$:



$$g(x,y) = \left\{\matrix{x & \text{ if }~~~x=y\\g(x-y,y) & \text{ if }~~~ x>y\\g(x,y-x) & \text{ if }~~~x

Edit:
Since this is a piecewise function, the base case confuses me. Am I supposed to do three separate base cases here? Also, the fact that this is recursive is not helping.
The first thing I would do is the base case where x and y equals 1, so: gcd(1,1) = 1 since x=y.
From there I don't really know where to go.




Apparently, knowing how to do this problem is a prerequisite for the class, which is stressing me out because I have never encountered an induction proof like this, and I really don't want to drop the class if I don't have to.

No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...