|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 686 (0x2ae) Types: TextFile Notes: UNIX file Names: »gcd.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code └─⟦f4b8d8c84⟧ UNIX Filesystem └─ ⟦this⟧ »libmp/gcd.c«
#include "mprec.h" /* * Gcd sets the value of the mint pointed to by "c" to the greatest * common divisor of the mints pointed to by "a" and "b". Note that * no assumption made on the distinctness of "a", "b" and "c". */ void gcd(a, b, c) register mint *a, *b, *c; { register mint *temp; mint al, bl, quot; /* make local copyies of arguments */ minit(&al); mcopy(a, &al); a = &al; minit(&bl); mcopy(b, &bl); b = &bl; /* calculate gcd by Euclidean algorithm */ minit("); while (!zerop(b)) { mdiv(a, b, ", a); temp = a; a = b; b = temp; } /* throw away garbage and return result */ mpfree(quot.val); mpfree(b->val); mpfree(c->val); *c = *a; }