0) || (ISARITH_cmp(1, $in_n2) > 0)) { //Input parameter(s) illegal. Must return FALSE. $out_gcd = FALSE; $out_icalcs = FALSE; } else { $i = -1; $out_icalcs[0]['dividend'] = $in_n1; $out_icalcs[0]['divisor'] = $in_n2; do { $i++; $out_icalcs[$i]['quotient'] = ISARITH_div($out_icalcs[$i]['dividend'], $out_icalcs[$i]['divisor']); $out_icalcs[$i]['remainder'] = ISARITH_mod($out_icalcs[$i]['dividend'], $out_icalcs[$i]['divisor']); if (ISARITH_cmp($out_icalcs[$i]['remainder'], 0) > 0) { $out_icalcs[$i+1]['dividend'] = $out_icalcs[$i]['divisor']; $out_icalcs[$i+1]['divisor'] = $out_icalcs[$i]['remainder']; } } while(ISARITH_cmp($out_icalcs[$i]['remainder'], 0) > 0); //Unless we completed in a single round, GCD is the last non-zero remainder. //Since the last remainder is zero to terminate the loop, this must be it. if ($i <= 0) $out_gcd = $out_icalcs[0]['divisor']; else $out_gcd = $out_icalcs[$i-1]['remainder']; } } ?>