Finding Factorial - Golang
Input:
5
package main
import (
"fmt"
)
func fact(n int) int {
if n == 0 {
return 1
} else {
return n * fact(n-1)
}
}
func main() {
fmt.Println(fact(5))
}
The above program will print the following output:
120
Input:
5
package main
import (
"fmt"
)
func fact(n int) int {
if n == 0 {
return 1
} else {
return n * fact(n-1)
}
}
func main() {
fmt.Println(fact(5))
}
The above program will print the following output:
120