Files
hello-algo/ja/codes/go/chapter_computational_complexity/recursion_test.go
Yudong Jin 7257641e0e Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese

* Fit Japanese homepage labels and localize heading permalinks

* Point Japanese contribution instructions to the Japanese preview

* Replace locale conditionals with multilingual UI tables
2026-10-30 02:12:26 +08:00

27 lines
577 B
Go

// File: recursion_test.go
// Created Time: 2023-08-28
// Author: Reanon (793584285@qq.com)
package chapter_computational_complexity
import (
"fmt"
"testing"
)
/* 実行用コード */
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)
}