Good for you! There's a small bug in your code (
remainder is uninitialized) but, otherwise, it should work... You can either initialize your variables, change your
while() loop into a
do{}while() loop, or both...
I was about to suggest this:
Code:
unsigned int GCD( unsigned int a, unsigned int b) {
 return b == 0 ? a : GCD( b, a % b);
}
It's needlessly recursive, so I would say that your implementation is better (and that you should stick with it!) but mine looks more fun...