Skip to content

Instantly share code, notes, and snippets.

@giwa
Last active August 29, 2015 14:14
Show Gist options
  • Save giwa/03557f5ad6c09ce0ed95 to your computer and use it in GitHub Desktop.
Save giwa/03557f5ad6c09ce0ed95 to your computer and use it in GitHub Desktop.
package main
import "fmt"
// この関数は基礎であるfact(0)にたどり着くまで自分自身を呼び続けます。
func fact(n int) int {
if n == 0 {
return 1
}
return n * fact(n-1)
}
func main() {
fmt.Println(fact(7))
}
$ go run recursion.go
5040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment