标签:style blog class code java color
1 public class T009 { 2 public static void main(String[] args){ 3 System.out.println(fibonacci(3)); 4 } 5 public static long fibonacci(int n){ 6 int[] result = {0,1}; 7 if(n<2) 8 return result[n]; 9 long fibminOne=1; 10 long fibminTwo=0; 11 long fibN = 0; 12 for(int i =2;i<=n;i++){ 13 fibN = fibminOne+fibminTwo; 14 fibminTwo=fibminOne; 15 fibminOne=fibN; 16 } 17 return fibN; 18 } 19 }
java实现——009Fibonacci数列,布布扣,bubuko.com
标签:style blog class code java color
原文地址:http://www.cnblogs.com/thehappyyouth/p/3716363.html