X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/8d771c4aaff5da72521c1af4746e482c95c8c8e4..9f49c854939cf36901a4a31e43abdb4ea440060f:/mp.c diff --git a/mp.c b/mp.c index ceb9142..038324a 100644 --- a/mp.c +++ b/mp.c @@ -1,7 +1,5 @@ /* -*-c-*- * - * $Id$ - * * Multiprecision arithmetic * * (c) 2004 Straylight/Edgeware @@ -929,6 +927,16 @@ end: return (z); } +static PyObject *meth__MP_factorial(PyObject *me, PyObject *arg) +{ + unsigned long i; + mp *x; + if (!PyArg_ParseTuple(arg, "OO&:factorial", &me, convulong, &i)) + return (0); + x = mp_factorial(i); + return mp_pywrap(x); +} + #define LOADOP(pre, py, name) \ static PyObject *meth__##py##_##name(PyObject *me, PyObject *arg) \ { \ @@ -2448,6 +2456,8 @@ fromstring(STR, radix = 0) -> (X, REST)\n\ Parse STR as a binary polynomial, according to radix. If radix is zero,\n\ read a prefix from STR to decide radix: allow `0' for octal, `0x' for hex\n\ or `R_' for other radix R.") + METH (_MP_factorial, "\ +factorial(I) -> I!: compute factorial") METH (_MP_loadl, "\ loadl(STR) -> X: read little-endian bytes") METH (_MP_loadb, "\