摘要:
非递归算法求Fibonacci比递归算法效率更优!public static int Fibonacci(int n) { int Result = 1; int temp1 = 0, temp2 = 1, j = 3; if (n == 1) { Result = 1; return Result; } else if (n == 2) { Result = 1; return Result; } while (j = n) { temp1 = temp2; temp2 = Result; Result = temp1 + temp2; j++; } return Result; } 阅读全文