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.
1 parent 5ebdf46 commit f5e8745Copy full SHA for f5e8745
Fibonacci Series
@@ -0,0 +1,25 @@
1
+class Fibonacci {
2
+ static int fib(int n)
3
+ {
4
+ int f[] = new int[n + 1];
5
+ int i;
6
+ f[0] = 0;
7
+
8
+ if (n > 0) {
9
+ f[1] = 1;
10
11
+ for (i = 2; i <= n; i++) {
12
+ f[i] = f[i - 1] + f[i - 2];
13
+ }
14
15
16
+ return f[n];
17
18
19
+ public static void main(String args[])
20
21
+ Scanner sc=new Scanner(System.in);
22
+ int n = sc.nextInt();
23
+ System.out.println(fib(n));
24
25
+}
0 commit comments