Computer Science, asked by shauryagupta450, 11 months ago

Write the javascript to display the fibonacci series : 0 1 1 2 3 5....

Answers

Answered by jot2282
0

coding :.

public class FibonacciCalc{

public static int fibonacciRecursion(int n){

if(n == 0){

return 0;

}

if(n == 1 || n == 2){

return 1;

}

return fibonacciRecursion(n-2) + fibonacciRecursion(n-1);

}

public static void main(String args[]) {

int maxNumber = 10;

System.out.print("Fibonacci Series of "+maxNumber+" numbers: ");

for(int i = 0; i < maxNumber; i++){

System.out.print(fibonacciRecursion(i) +" ");

}

}

}

Similar questions