C#递归算法
看到这个还挺不错的,不知道还有没有更高效的了!大家可以沾上来以供参考!
1 private static int Digui(int j) 2 { 3 int[] arr = new int[30]; 4 arr[0] = 1; 5 arr[1] = 1; 6 int first = arr[0]; 7 int second = arr[1]; 8 for (int i=2; i <j; i++) 9 { 10 arr[i] = first + second; 11 first = second; 12 second = arr[i]; 13 } 14 return arr[j-1]; 15 }