Learning fibonacci implementations in few ways!
from pygorithm.fibonacci import recursion as fib_recursion
sequence = fib_recursion.get_sequence(10)
print(sequence) # [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]- Fibonacci implementations available:
- Generator
- Golden ratio
- Memorization (which saves some recursions to avoid computation of same series again and again)
- Recursion
- Get the code used for any of the implementation
from pygorithm.fibonacci import recursion as fib_recursion
code = fib_recursion.get_code()
print(code)- To see all the available functions in a module there is a modules() function available. For example,
>>> from pygorithm.fibonacci import modules
>>> modules()
['generator', 'goldenratio', 'memoization', 'recursion']- Functions and their uses
.. function:: get_sequence(number)
- number : arbitrary integer, that need to be calculated in Fibonacci number type
- Return Value : return Fibonacci value by specified number as integer
.. function:: get_code()
- Return Value : returns the code for the
get_sequence()function