write java program to print Fibonacci series using arrays
Answers
Answered by
0
output:. Fibonacci Series of 10 numbers: 0 1 1 2 3 5 8 13 21 34
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
Math,
5 months ago
Social Sciences,
5 months ago
English,
5 months ago
India Languages,
11 months ago
Math,
11 months ago
Physics,
1 year ago
Physics,
1 year ago