发布网友 发布时间:2022-05-04 21:24
共3个回答
热心网友 时间:2022-06-26 00:29
#include <iostream>热心网友 时间:2022-06-26 00:29
main()热心网友 时间:2022-06-26 00:30
public class FibTest { public static void main(String[] arags){ long begin = System.currentTimeMillis(); System.out.println(fib(10)); long end = System.currentTimeMillis(); System.out.println(end - begin); } public static long fib(int n){ if(n < 3) return 1; else{ long a = 1; long b = 1; for(int i = 2 ; i < n-1 ;i++){ b = a + b; a = b - a; System.out.println("a = "+a +" b = "+b); } return a + b; } } }