Answers for "golang recursive function example"

Go
0

golang recursive function example

package main

import "fmt"

func fact(n int) int {
    if n == 0 {
        return 1
    }
    return n * fact(n-1)
}
func main() {
    fmt.Println(fact(7))
}
Posted by: Guest on March-11-2021

Browse Popular Code Answers by Language