Q:

Java Program to display Fibonacci series

0

Program to display Fibonacci series up to a certain limit

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

 public class demo1 
{
 public static void main(String[] args) 
 {
 int limit = 20;
 long[] series = new long[limit];
 series[0] = 0;
 series[1] = 1;
 for(int i=2; i < limit; i++){
 series[i] = series[i-1] + series[i-2];
 }
 System.out.println("Fibonacci Series upto " + limit);
 for(int i=0; i< limit; i++){
 System.out.print(series[i] + " ");
 }
 }
 }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now