Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shockalotti/7fa310e915ee66766039 to your computer and use it in GitHub Desktop.
Save shockalotti/7fa310e915ee66766039 to your computer and use it in GitHub Desktop.
Go Golang - recursion function, calculate factorial
package main
import "fmt"
func factorial(x uint) uint {
if x == 0 {
return 1
}
return x * factorial(x-1)
}
func main() {
x := uint(5)
calcFactorial := factorial(x)
fmt.Println(calcFactorial)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment