Skip to content

Fix #1: Implement fibonacci with edge-case ValueError handling - #6

Open
dogthebughunter wants to merge 1 commit into
gougousongsong:mainfrom
dogthebughunter:fix/fibonacci-edge-case-handling
Open

Fix #1: Implement fibonacci with edge-case ValueError handling#6
dogthebughunter wants to merge 1 commit into
gougousongsong:mainfrom
dogthebughunter:fix/fibonacci-edge-case-handling

Conversation

@dogthebughunter

Copy link
Copy Markdown

Description

Fixes #1

Solution Overview

  • Implemented fibonacci(n) in src/math_utils.py using an $O(n)$ iterative calculation.
  • Added input validation raising ValueError('n must be non-negative') when $n < 0$.
  • Added comprehensive unit test coverage in tests/test_math_utils.py for standard numbers (0, 1, 2, 3, 5, 10, 20) and negative numbers (-1, -10).

Verification & Test Evidence

All unit tests passed with 0 failures or regressions:

tests/test_math_utils.py::test_add PASSED                                [ 16%]
tests/test_math_utils.py::test_multiply PASSED                           [ 33%]
tests/test_math_utils.py::test_fibonacci_base_and_normal_cases PASSED    [ 50%]
tests/test_math_utils.py::test_fibonacci_negative_edge_cases PASSED      [ 66%]
tests/test_string_utils.py::test_reverse_string PASSED                   [ 83%]
tests/test_string_utils.py::test_to_uppercase PASSED                     [100%]
============================== 6 passed in 0.07s ===============================

Bounty Payout Details

  • EVM (Base / Ethereum) Address: 0xaB11FaD6A8d3FE23F79f30E11a0fbdCeb969E170
  • Solana Address: 4JVAkfRfCygp5kYHMEUUrB6bjanwTzTMENZBsVJuwi9F
  • Contact Email: admin@x.freysa.dev / code7creations@gmail.com

…andling

- Implemented iterative O(n) fibonacci(n) sequence generator
- Added input validation raising ValueError('n must be non-negative') for n < 0
- Added comprehensive unit tests in tests/test_math_utils.py
- Verified all 6 pytest unit tests pass
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.

Add fibonacci function with edge case handling

1 participant