日期:2014-05-18 浏览次数:20849 次
public static long Fibonacci(int n) { if (n < 2) return 1; long a = 1; long b = 1; for (int i = 2; i < n; i++) { b = a + b; a = b - a; } return a + b; }
------解决方案--------------------
100的时候。。int超出。。。改个类型~~
static void Main(string[] args) { ulong x = 0, y = 1; for (ulong j = 1; j < 100; j++, y = x + y, x = y - x) Console.Write(y + " "); Console.Read(); }