committed by
Aditya Bhargava
parent
88cf645af9
commit
38d50415e8
15
03_recursion/Golang/03_factorial/Factorial.go
Normal file
15
03_recursion/Golang/03_factorial/Factorial.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func fact(x int) int {
|
||||
if x == 1 {
|
||||
return 1
|
||||
} else {
|
||||
return x * fact(x-1)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(fact(5))
|
||||
}
|
||||
Reference in New Issue
Block a user