标签:system turn res lse == print oid ret date
import java.util.Date; public class fff { public static void main(String[] args) { Date start = new Date(); long a = fibo(50); System.out.println(a); //25172538050 Date end = new Date(); int j = (int) (end.getTime() - start.getTime()); System.out.println("所用时间-->"+j); //所用时间-->28101 //28秒 } public static long fibo(int n) { if (n == 1 || n == 2) { return 2; } else { return fibo(n - 1) + fibo(n - 2); } } }
package main import "fmt" import "time" func fibo(n int64) uint64 { if n == 1 || n == 2 { return 2 } else { return fibo(n-1) + fibo(n-2) } } func main() { start := time.Now().Unix() res := fibo(50) end := time.Now().Unix() fmt.Println(res) //25172538050 j := int64(end) - int64(start) fmt.Println("所用时间-->", j) //所用时间--> 40秒 }
import time def fibo(n): if n == 1 or n == 2: return 2 else: return fibo(n - 1) + fibo(n - 2) start = time.time() res = fibo(50) end = time.time() print(res) # 25172538050 print(end - start) # 2801.014867544174
标签:system turn res lse == print oid ret date
原文地址:https://www.cnblogs.com/yzg-14/p/12235377.html