Skip to content

Latest commit

 

History

History
55 lines (35 loc) · 1.31 KB

File metadata and controls

55 lines (35 loc) · 1.31 KB

Fibonacci

Learning fibonacci implementations in few ways!

Quick Start Guide

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]

Features

  • 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']

Implementations API

  • 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