while (a != b) {
     if (a > b)
        a -= b;
     else if (a < b)
        b -= a;
}
nzd = a;
while (b != 0) {
   mod = a % b;
   a = b;
   b = mod;
}
nzd = a;