Making Fibonacci faster [duplicate]
问题 This question already has answers here : nth fibonacci number in sublinear time (14 answers) Closed 4 years ago . I was required to write a simple implementation of Fibonacci's algorithm and then to make it faster . Here is my initial implementation public class Fibonacci { public static long getFibonacciOf(long n) { if (n== 0) { return 0; } else if (n == 1) { return 1; } else { return getFibonacciOf(n-2) + getFibonacciOf(n-1); } } public static void main(String[] args) { Scanner scanner =