From 6313f40e5130ed03dcadc0a464865915f07f80ae Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 27 Feb 2015 14:40:26 +0000 Subject: [PATCH] mp.c: Binding for `mp_fibonacci'. --- catacomb-python.h | 1 + mp.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/catacomb-python.h b/catacomb-python.h index a384097..2890289 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -75,6 +75,7 @@ #include #include #include +#include #include #include diff --git a/mp.c b/mp.c index 038324a..1177a60 100644 --- a/mp.c +++ b/mp.c @@ -937,6 +937,15 @@ static PyObject *meth__MP_factorial(PyObject *me, PyObject *arg) return mp_pywrap(x); } +static PyObject *meth__MP_fibonacci(PyObject *me, PyObject *arg) +{ + long i; + mp *x; + if (!PyArg_ParseTuple(arg, "Ol:fibonacci", &me, &i)) return (0); + x = mp_fibonacci(i); + return mp_pywrap(x); +} + #define LOADOP(pre, py, name) \ static PyObject *meth__##py##_##name(PyObject *me, PyObject *arg) \ { \ @@ -2458,6 +2467,8 @@ 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_fibonacci, "\ +fibonacci(I) -> F(I): compute Fibonacci number") METH (_MP_loadl, "\ loadl(STR) -> X: read little-endian bytes") METH (_MP_loadb, "\ -- 2.11.0