Skip to content

Add Python Fibonacci calculation function#3

Open
codemie-anton[bot] wants to merge 1 commit into
test1from
test3
Open

Add Python Fibonacci calculation function#3
codemie-anton[bot] wants to merge 1 commit into
test1from
test3

Conversation

@codemie-anton

@codemie-anton codemie-anton Bot commented Feb 2, 2026

Copy link
Copy Markdown

Description

This PR adds a comprehensive Python module for Fibonacci number calculations with multiple implementation approaches.

Changes

  • Created fibonacci.py with three different Fibonacci calculation functions:
    • fibonacci(n): Recursive implementation for calculating the nth Fibonacci number
    • fibonacci_iterative(n): Iterative implementation (more efficient for larger numbers)
    • fibonacci_sequence(count): Generates a list of Fibonacci numbers

Features

  • Proper error handling for negative inputs
  • Comprehensive docstrings for all functions
  • Example usage in the __main__ block
  • Both 0-indexed calculations and sequence generation

Testing

The module includes example usage that demonstrates:

  • Calculating individual Fibonacci numbers (0-9)
  • Using the iterative approach for larger numbers (15th position)
  • Generating a sequence of the first 15 Fibonacci numbers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants