/* -*-c-*-
*
- * $Id: primorial.c,v 1.1 1999/12/22 15:51:02 mdw Exp $
+ * $Id: primorial.c,v 1.2 2000/07/09 21:31:43 mdw Exp $
*
* Computes the product of the small primes
*
/*----- Revision history --------------------------------------------------*
*
* $Log: primorial.c,v $
+ * Revision 1.2 2000/07/09 21:31:43 mdw
+ * Use `mpmul'.
+ *
* Revision 1.1 1999/12/22 15:51:02 mdw
* Calculate product of small primes for DSA prime search.
*
/*----- Header files ------------------------------------------------------*/
#include "mp.h"
+#include "mpmul.h"
#include "primetab.h"
/*----- Global variables --------------------------------------------------*/
void primorial_setup(void)
{
- mp *p;
- mp q;
- mpw qw;
+ mp *p = MP_NEW;
+ mpmul mm = MPMUL_INIT;
int i;
if (primorial)
return;
- mp_build(&q, &qw, &qw + 1);
- p = MP_ONE;
+
for (i = 0; i < NPRIME; i++) {
- qw = primetab[i];
- p = mp_mul(p, p, &q);
+ p = mp_fromuint(p, primetab[i]);
+ mpmul_add(&mm, p);
}
+ mp_drop(p);
+ primorial = mpmul_done(&mm);
mp_minimize(p);
- primorial = p;
}
/*----- That's all, folks -------------------------------------------------*/