Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create a class that computes the Fibonacci number for a given input. The Fibonac

ID: 3664508 • Letter: C

Question

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) = fibonacci(n1) + fibonacci(n–2)

You will create a Java class named “Fibonacci” that computes and prints out the Fibonacci sequence for that 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:

$ java Fibonacci 6

fibo(0) = 0

fibo(1) = 1

fibo(2) = 1

fibo(3) = 2

fibo(4) = 3

fibo(5) = 5

fibo(6) = 8

Explanation / Answer

import java.util.*;

import java.io.*;

class Fibonacci

{

public static void main(String args[])

{

int fibocount=6;

fibo(0) = 0

fibo(1) = 1

fibo(2) = 1

fibo(3) = 2

fibo(4) = 3

fibo(5) = 5

fibo(6) = 8

for(int i=0;i<fibocount;i++)

{

fibo(n)=fibonacci(n1)+fibonacci(n–2);

}

System.out.println(“fibonacci series is”);

}