mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-20 18:52:36 +08:00
* 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
27 lines
577 B
Go
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)
|
|
}
|