Computers and Technology

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
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:30, megkate
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
image
Computers and Technology, 23.06.2019 14:00, ava5015
What is html ? give a small description about html
Answers: 2
image
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
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
Health, 09.04.2021 19:10
Konu
Mathematics, 09.04.2021 19:10
Konu
Mathematics, 09.04.2021 19:10