--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: factorial.c,v 1.1 2000/07/09 21:30:49 mdw Exp $
+ *
+ * Example factorial computation
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: factorial.c,v $
+ * Revision 1.1 2000/07/09 21:30:49 mdw
+ * Demo program to compute factorials.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <mLib/quis.h>
+#include <mLib/report.h>
+
+#include "mpmul.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ unsigned long x;
+ char *p;
+ mp *f;
+
+ ego(argv[0]);
+
+ if (argc != 2) {
+ pquis(stderr, "Usage: $ integer\n");
+ exit(EXIT_FAILURE);
+ }
+ x = strtoul(argv[1], &p, 0);
+ if (*p)
+ die(EXIT_FAILURE, "bad integer `%s'", argv[1]);
+ f = mp_factorial(x);
+ mp_writefile(f, stdout, 10);
+ fputc('\n', stdout);
+ mp_drop(f);
+ return (0);
+}
+
+/*----- That's all, folks -------------------------------------------------*/