Merge pull request #8676 from antmordel/master

BAEL-3635 Intro to Alibaba Arthas
This commit is contained in:
Jonathan Cook 2020-03-18 07:41:50 +01:00 committed by GitHub
commit fa97ab6c43
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.arthas;
import java.io.IOException;
import static java.lang.String.format;
public class FibonacciGenerator {
public static void main(String[] args) throws IOException {
System.out.println("Press a key to continue");
System.in.read();
for (int i = 0; i < 100; i++) {
long result = fibonacci(i);
System.out.println(format("fib(%d): %d", i, result));
}
}
public static long fibonacci(int n) {
if (n == 0 || n == 1) {
return 1L;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
}