We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d3e3f68 + 14be2d1 commit 0cca19fCopy full SHA for 0cca19f
Fabo.java
@@ -0,0 +1,31 @@
1
+public class Fabo {
2
+ public static int fibonacciRecursion(int n,int[]arr){
3
+
4
+ /* if(n == 0){
5
+ return 0;
6
+ }
7
+ if(n == 1 || n == 2){
8
+ return 1;*/
9
10
+ if(n<=1){
11
+ return n;
12
13
+ if(arr[n]!=0){
14
+ return arr[n];
15
16
17
18
+ int ans=fibonacciRecursion(n-2,arr) + fibonacciRecursion(n-1,arr);
19
+ return arr[n]=ans;
20
21
22
23
+ public static void main(String args[]) {
24
+ int maxNumber = 6;
25
+ System.out.print("Fibonacci Series of " + maxNumber + " numbers: ");
26
+ int []arr=new int[maxNumber+1];
27
+ int ans=fibonacciRecursion(maxNumber,arr);
28
+ System.out.println(ans);
29
30
31
+}
0 commit comments