You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
205 B
Go
17 lines
205 B
Go
6 years ago
|
package main
|
||
|
import "fmt"
|
||
|
|
||
|
func factorial(num int) int {
|
||
|
if num == 0 {
|
||
|
return 1
|
||
|
}
|
||
|
return num * factorial(num - 1)
|
||
|
}
|
||
|
|
||
|
|
||
|
func main() {
|
||
|
num := 10
|
||
|
result := factorial(num)
|
||
|
fmt.Println(result)
|
||
|
}
|