Skip to main content

Fibonacci Module

A Python module for calculating Fibonacci numbers with multiple implementations.

Features

  • Iterative Fibonacci: Efficient O(n) time complexity implementation
  • Recursive Fibonacci: Classic recursive approach
  • Fibonacci Sequence: Generate a list of Fibonacci numbers
  • Fibonacci Check: Test if a number is in the Fibonacci sequence

Installation

pip install fibonacci-module

Usage

from fibonacci.fibonacci import fibonacci_iterative, fibonacci_recursive, fibonacci_sequence, is_fibonacci

# Calculate the 10th Fibonacci number iteratively
print(fibonacci_iterative(10))  # Output: 55

# Calculate the 10th Fibonacci number recursively
print(fibonacci_recursive(10))  # Output: 55

# Generate the first 10 Fibonacci numbers
print(fibonacci_sequence(10))  # Output: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

# Check if a number is a Fibonacci number
print(is_fibonacci(13))  # Output: True
print(is_fibonacci(14))  # Output: False

Functions

fibonacci_iterative(n)

Calculate the nth Fibonacci number using an iterative approach.

  • Parameters: n (int) - The position in the Fibonacci sequence (0-indexed)
  • Returns: int - The nth Fibonacci number
  • Raises: ValueError if n is negative

fibonacci_recursive(n)

Calculate the nth Fibonacci number using recursion.

  • Parameters: n (int) - The position in the Fibonacci sequence (0-indexed)
  • Returns: int - The nth Fibonacci number
  • Raises: ValueError if n is negative

fibonacci_sequence(n)

Generate a list of the first n Fibonacci numbers.

  • Parameters: n (int) - The number of Fibonacci numbers to generate
  • Returns: list - A list containing the first n Fibonacci numbers
  • Raises: ValueError if n is negative

is_fibonacci(num)

Check if a number is in the Fibonacci sequence.

  • Parameters: num (int) - The number to check
  • Returns: bool - True if the number is a Fibonacci number, False otherwise

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fibonacci_module-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fibonacci_module-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file fibonacci_module-0.1.0.tar.gz.

File metadata

  • Download URL: fibonacci_module-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for fibonacci_module-0.1.0.tar.gz
Algorithm Hash digest
SHA256 663cfa91b64f84c67fe031e7ecc9b52567a4d0de40e20b4ebf24ce8282ca9fe3
MD5 4eddaebe45a0256f45e90220c7fe6884
BLAKE2b-256 b26149c2c9ae1df9394ea1fd91e59b204309fdaf25c69a4746dab12e6e9b5bbb

See more details on using hashes here.

File details

Details for the file fibonacci_module-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fibonacci_module-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e96e4a6ed56d884ce6213ce0713286c17fbdd82156dc6e374500022a3c05d65b
MD5 9c2085e995b1cd461412b085fd1fb668
BLAKE2b-256 0f853142f712a9f04b6b24d6cfbcd33b5168468dd627c3c0096cd68d9e38012d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page