Files
hello-algo/en/codes/go/chapter_computational_complexity/recursion_test.go
Yudong Jin 14c314c08c Retranslate the complete English edition from Simplified Chinese (#2010)
* Retranslate the complete English edition from Simplified Chinese

* Polish three English explanations after reader-focused review
2026-10-31 03:35:51 +08:00

27 lines
536 B
Go

// 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("\nSum from recursion: res = ", res)
res = forLoopRecur(n)
fmt.Println("\nSum from simulating recursion with iteration: res = ", res)
res = tailRecur(n, 0)
fmt.Println("\nSum from tail recursion: res = ", res)
res = fib(n)
fmt.Println("\nFibonacci term", n, "is", res)
}