feat(go): add iterration/recursion & fix bugs (#698)

This commit is contained in:
Reanon
2023-08-28 13:35:39 +08:00
committed by GitHub
parent 8347c2da36
commit 20f53e9fc4
6 changed files with 149 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
// 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 = tailRecur(n, 0)
fmt.Println("\n尾递归函数的求和结果 res = ", res)
res = fib(n)
fmt.Println("\n斐波那契数列的第", n, "项为", res)
}