enter image description hereWAP to generate negative Fibonacci numbers using recursion, Description:
In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence 0, 1, -1, 2, -3, 5, -8, 13, -21, 34, -55, 89, -144 . . .
By definition, the first two numbers in the Fibonacci sequence are 0 and 1, each subsequent number is the subtraction of the previous two
Pr-requisites:
Arithmetic Operators
Recursions
Objective: –
To understand the concept of
Recursive Functions
Inputs: –
Integers N
Sample execution: –
Test Case 1 :
Enter a number: -8
0, 1, -1, 2, -3, 5, -8
Test Case 2:
Enter a number: -10
0, 1, -1, 2, -3, 5, -8
Test Case 3:
Enter a number: -21
0, 1, -1, 2, -3, 5, -8, 13, -21
Test Case 3:
Enter a number: 21
Invalid input
use the function
tried all possible ways i know but for some test cases i am not getting output
— Program output —
Enter a number: Invalid input
— Expected output (numbers)—
0
Test 3: -2
Incorrect program output
— Input —
-2
— Program output —
Enter a number: 0, 1, -1
— Expected output (text)—
0, 1, -1, 2
Test 5: -15
Incorrect program output
- Input —`
-15
— Program output —
Enter a number: 0, 1, -1, 2, -3, 5, -8
— Expected output (text)—
0, 1, -1, 2, -3, 5, -8, 13
V M BHUVANESH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.