Need help coding this in java and using putty to do it on. I have to connect to
ID: 3880443 • Letter: N
Question
Need help coding this in java and using putty to do it on. I have to connect to the et791.ni.utoledo.edu server to code this at on putty.
For this assignment, you will create a class that computes the Fibonacci number for a given input. The Fibonacci number is an important construct in mathematics. The definition of the Fibonacci number is given below: fibonacci(0) 0 fibonacci( 1 ) = 1 fibonacci(n) = fibonaccin- 1) + fibonacci(n-2) You will create Java class named "Fibonacci" tha computes and prints out the Fibonacci sequence for thal number. The Fibonacci sequence is simply the list of Fibonacci numbers from 0 up to the Fibonacci number of the input value. Your program should take one argument. This argument is the number for which you will compute the Fibonacci sequence. Below is an example of running the Fibonacci class with an input of 6. The output of the program is all the Fibonacci numbers from 0 to 6 S java Fibonacci 6 fibo(0 0 fibo(1 ) = 1 tibo 2)1 fibo(3) -2 fibo(4)-3 fibo 5)-5 fibo(6)-S Your program should be compiled and tested on et791 server.Explanation / Answer
class Fibonacci{
public static long fibonacci (int i)
{
if (i == 0) return 0;
if (i<= 2) return 1;
long fibTerm = fibonacci(i - 1) + fibonacci(i - 2);
return fibTerm;
}
public static void main(String[] args)
{
int val = Integer.parseInt(args[0]);
for (int i = 0; i <= val; i++) {
System.out.println("fibo(" + i+ ") = " + fibonacci(i));
}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.