Skip to content

Commit 53f5f8d

Browse files
Added FibonacciArray.java
1 parent ba9960c commit 53f5f8d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package tech.bingulhan.others;
2+
3+
public class FibonacciArray {
4+
5+
public static int fibonacci(int n) {
6+
if (n <= 1) {
7+
return n;
8+
} else {
9+
return fibonacci(n - 1) + fibonacci(n - 2);
10+
}
11+
}
12+
13+
public static void main(String[] args) {
14+
int n = 32; // İstenilen Fibonacci serisi eleman sayısı
15+
System.out.println("Fibonacci series up to " + n + " elements:");
16+
17+
for (int i = 0; i < n; i++) {
18+
System.out.print(fibonacci(i) + " ");
19+
}
20+
}
21+
22+
}

0 commit comments

Comments
 (0)