Answer to Question #224073 in Java | JSP | JSF for Kavin

Question #224073
Write a program to create a multilevel package and also creates a reusable class to
generate Fibonacci series, where the function to generate fibonacii series is given in a
different file belonging to the same package.
1
Expert's answer
2021-08-10T17:41:35-0400
import java.util.Scanner;


public class FibonacciSeries {


 public static void main(String[] args) {
  int len;
  Scanner in = new Scanner(System.in); 
  System.out.print("Enter length: ");
  len = sc.nextInt();
  int[] arr = new int[len];
  arr[0] = 0;
  arr[1] = 1;
  
  for (int i = 2; i < len; i++) {
   arr[i] = arr[i - 1] + arr[i - 2];
  }


  System.out.println("Fibonacci Series: ");
  for (int i = 0; i < len; i++) {
        System.out.print(arr[i] + " ");
  }
 }


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS