some new things, mostly not working or finished
This commit is contained in:
22
fib/fib.java
Normal file
22
fib/fib.java
Normal file
@@ -0,0 +1,22 @@
|
||||
public class recursive {
|
||||
|
||||
public static int fibonacci(int max) {
|
||||
|
||||
if (max <= 1) {
|
||||
return max;
|
||||
}
|
||||
|
||||
else {
|
||||
return fibonacci(max - 2) + fibonacci(max - 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int max = 10;
|
||||
for (int i = 0; i < max; i++) {
|
||||
System.out.print(fibonacci(i) + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user