Using Java, The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Using Java, The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous t
Using Java, The Fibonacci sequence begins with 0 and then 1follows. All subsequent values are the sum ofthe previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Completethe fibonacci() method, which hasan index, n, as parameter and returns the nth value in thesequence. Any negative index valuesshould return -1.Examples:Input: 7Output: fibonacci(7) is 13Input: 11Output: fibonacci(7) is 89Input: 23Output: fibonacci(7) is 28657