go的math.big用法
点击查看代码
package main
import (
"fmt"
"math/big"
)
func genFibLst(n int) (a []string) {
n1 := big.NewInt(1)
n2 := big.NewInt(1)
fmt.Printf("n1=%s, n2=%s, n1.string=%s\n",n1,n2,n1.String())
for n > 0 {
a = append(a, n1.String())
tmp := n1.Add(n1, n2)
fmt.Printf("n1=%s, n2=%s, a=%v,tmp=%s \n",n1,n2,a,tmp)
n1 = n2
n2 = tmp
n--
}
return a
}
func main() {
lst := genFibLst(10)
for index, val := range lst {
fmt.Println(index + 1, val)
}
}
写入自己的博客中才能记得长久