![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 05.05.2021 17:50, michellectucker1982
The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fibonacci() method, which takes in an index, n, and returns the nth value in the sequence. Any negative index values should return -1.
Ex: If the input is: 7
the out put is :fibonacci(7) is 13
Note: Use recursion and DO NOT use any loops. // is this mean i don't have to use loops? for (int i = 1; i<= n; ++i)
import java. util. Scanner;
public class LabProgram {
public static int fibonacci(int n) {
/* Type your code here. */
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int startNum;
System. out. println("Enter your number: ");
startNum = scnr. nextInt();
System. out. println("fibonnaci(" + startNum + ") is " + fibonacci(startNum));
}
}
![answer](/tpl/images/cats/otvet.png)
Answers: 3
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 21:30, quintonps12
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 10:30, johngayden46
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
Do you know the correct answer?
The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the pr...
Questions in other subjects:
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/health.png)
Health, 09.04.2021 19:10
![Konu](/tpl/images/cats/mkx.png)
![Konu](/tpl/images/cats/istoriya.png)
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 09.04.2021 19:10
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 09.04.2021 19:10
![Konu](/tpl/images/cats/mat.png)