PARIdo(q{ mygcd(a, b) = { if (a > b, { mygcd(b, a); }, { if (a == 0, { b; }, { mygcd(b % a, a); }); }); } }); print PARI("mygcd(12,8)");