Created
May 28, 2014 01:33
-
-
Save shockalotti/7fa310e915ee66766039 to your computer and use it in GitHub Desktop.
Go Golang - recursion function, calculate factorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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