Addition of fibonacci function

Like the factorial() function of the math mode module, the addition of the Fibonacci series would be of great use. Hereby, I consider the addition of the fibonacci() function of great use.
Please let me know how’s the idea?

SymPy has a fibonacci function that handles integers as well as general complex numbers:

>>> from sympy import fibonacci
>>> fibonacci(10)
>>> fibonacci(10.5)
>>> fibonacci(10.5+1j)
62.0353078744441 + 32.413150678686*I


Yeah but I meant 0,1,1,2,3,5,8,…

>>> from sympy import fibonacci
>>> print(','.join(str(fibonacci(i)) for i in range(7)) + ",...")

What is the practical use-case? I’ve only ever used fibonacci-like functions in programming exercises, whereas factorial is useful in statistics.


Though there’s nothing such but still it would be like adding an infinitely small point.

Typically, to add new features you need prove that the feature a) solves a practical problem and b) is not trivial to implement yourself. While I am not a core developer I’m pretty sure this suggested features fail both criteria.


Ok. Thankyou Jacob.

Yes. Also, computing terms of the Fibonacci sequence is one of the most frequently given exercises for programming newbies. It would be sad to give thousands of students an opportunity to cheat :slight_smile:


The practical use is as a test-case for those programming exercises :innocent:

1 Like

By Nishant Bansal via Discussions on at 04Aug2022 18:14:

Ok. Thankyou Jacob.

The usual suggestion, if you want a function not provided by the stdlib
but haven’t make an empiricly string case for its necessity, is to
provide it yourself. In principle you can put it in a module and
publish it. That way anyone (yourself included in other projects) can
install and use it.

As an example of posting trivial stuff, here’s my cs.numeric module:

which is actually available on PyPI:

only a pip install cs.numeric away.

It ocontains almost nothing of value, but I needed somewhere to put its
intif(f) function, which returns int(f) if that round trips with the
original float value, otherwise the original float. This was for
somewhere I wanted to present an int where possible, but preserve the
float value if that lost precision.

The module itself is of little value to others (it supports something
else I’ve got on PyPI), but it’s a sensible route for publishing a
single function like fibonacci() for you or others to use.

Cameron Simpson