Skip to content

Commit 0042d17

Browse files
committed
Fix fib c-implementation
1 parent 6208387 commit 0042d17

File tree

1 file changed

+3
-1
lines changed
  • examples/c_extension_example/src

1 file changed

+3
-1
lines changed

examples/c_extension_example/src/lib.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ fib(PyObject *self, PyObject *args)
2929

3030
int previous = 1;
3131
int current = 1;
32+
int temp;
3233
while (current < limit)
3334
{
35+
temp = current;
3436
current = current + previous;
35-
previous = current;
37+
previous = temp;
3638

3739
// "Box" The current value to convert it to a Python int, then append it to the numbers Python list.
3840
PyObject *newElement = PyLong_FromLong(current);

0 commit comments

Comments
 (0)