Fibonacci Sequence

Easy
9
2
62.5% Acceptance

In this lab, you are tasked with implementing a Python function named fibonacci_numbers. This function should take an integer N as input and return a tuple of three Fibonacci numbers: the (N-1)th, Nth, and (N+1)th in the sequence.

Function Output

Your function should return a tuple of three numbers, adhering to the following rules:

  • If N is 1 or greater, return the (N-1)th, Nth, and (N+1)th Fibonacci numbers.
  • If N is 0 or negative, return -1 for non-existent Fibonacci numbers.

Examples

  1. Example 1:

    • Input: fibonacci_numbers(5)
    • Output: (3, 5, 8)
    • Explanation: The 4th, 5th, and 6th Fibonacci numbers are 3, 5, and 8, respectively.
  2. Example 2:

    • Input: fibonacci_numbers(0)
    • Output: (-1, -1, 0)
    • Explanation: As the 0th and -1st Fibonacci numbers do not exist, they are represented as -1. The 1st Fibonacci number is 0.

Edge Cases

  • Negative Input: For any negative input, your function should return (-1, -1, -1), indicating non-existent Fibonacci indices.
  • Zero Input: For an input of 0, the function should return (-1, -1, 0). Here, both -1 and 0 are considered as non-existent in the Fibonacci sequence context.

Focus on handling these edge cases correctly while ensuring your function accurately calculates the Fibonacci numbers for positive inputs.