go的时间格式和斐波那契函数

点击查看代码
package main

import (
	"fmt"
	"time"
)

func fibonacci(n int) uint64 {
	if n <= 2 {
		return uint64(1)
	}
	return fibonacci(n - 1) + fibonacci(n - 2)
}

func main() {
	fmt.Println(time.Now().Format("2006-01-02 15:04:05.000"))
	start_time := time.Now()
	fmt.Println(fibonacci(44))
	end_time := time.Now()
	fmt.Printf("cost: %d us\n", (end_time.UnixNano() - start_time.UnixNano()) / 1000)
	fmt.Println(start_time.Unix())
}
posted @ 2022-03-04 23:50  ty1539  阅读(17)  评论(0编辑  收藏  举报