/
githubmirror
/
hello-algo
Обзор
Документация
Войти
/
githubmirror
/
hello-algo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
codes/go/chapter_computational_complexity/recursion_test.go
26 строк
555 B
Nepenthe
feat(go): add forLoopRecur func (#816)
07 окт 2023, 16:47
Не верифицирован
07 окт 2023, 16:47
61e1d1f
Код
Авторство
О чём код?
// File: recursion_test.go // Created Time: 2023-08-28 // Author: Reanon (793584285@qq.com) package chapter_computational_complexity import ( "fmt" "testing" ) /* Driver Code */ func TestRecursion(t *testing.T) { n := 5 res := recur(n) fmt.Println("\n递归函数的求和结果 res = ", res) res = forLoopRecur(n) fmt.Println("\n使用迭代模拟递归求和结果 res = ", res) res = tailRecur(n, 0) fmt.Println("\n尾递归函数的求和结果 res = ", res) res = fib(n) fmt.Println("\n斐波那契数列的第", n, "项为", res) }