I've added Gcd and factorial to core.ops, see attachement.
Dan is this something you want?
I also have "least common multiple" and "binomial" implementation
waiting. If you want them i can can make a patch
/Josef
--- core.ops.orig Tue Jun 11 10:03:19 2002
+++ core.ops Tue Jun 11 10:08:32 2002
@@ -2433,8 +2433,92 @@
=cut
+########################################
-###############################################################################
+=head2 Other mathematical operations
+
+Implementations of various mathematical operations
+
+=over 4
+
+=cut
+
+
+########################################
+
+=item B<gcd>(out INT, in INT, in INT)
+
+=item B<gcd>(out INT, in NUM, in NUM)
+
+Greatest Common divisor of $2 and $3.
+
+=cut
+
+inline op gcd(out INT, in INT, in INT) {
+
+UINTVAL q = 0;
+UINTVAL c = 0;
+ while ($3 != 0) {
+ q = floor( (FLOATVAL)$2/$3 );
+ c = $2 - $3*q;
+ $2 = $3;
+ $3 = c;
+ }
+ $1 = $2;
+ goto NEXT();
+}
+
+inline op gcd(out INT, in NUM, in NUM) {
+
+UINTVAL q = 0;
+UINTVAL c = 0;
+ while ($3 != 0) {
+ q = floor( (FLOATVAL)$2/$3 );
+ c = $2 - $3*q;
+ $2 = $3;
+ $3 = c;
+ }
+ $1 = $2;
+ goto NEXT();
+}
+
+
+########################################
+
+=item B<fact>(out INT, in INT)
+
+=item B<fact>(out NUM, in INT)
+
+Factorial, n!. Calculates the product of 1 to N.
+
+=cut
+
+inline op fact(out INT, in INT) {
+
+UINTVAL i = $2;
+UINTVAL q = 1;
+ while(i>0) {
+ q = q*i;
+ i--;
+ }
+ $1 = q;
+ goto NEXT();
+}
+
+inline op fact(out NUM, in INT) {
+
+UINTVAL i = $2;
+UINTVAL q = 1;
+ while(i>0) {
+ q = q*i;
+ i--;
+ }
+ $1 = q;
+ goto NEXT();
+}
+
+
+########################################
=head2 Bitwise logical operations