dave on Nostr: package main import "fmt" func factorial(number int) int { // Base Case if number == ...
package main
import "fmt"
func factorial(number int) int {
// Base Case
if number == 0 {
return 1
}
// Recursive Case
return number * factorial(number-1)
}
func main() {
fmt.Println("Factorial of 4 is:", factorial(4))
}
Published at
2023-02-07 17:20:51Event JSON
{
"id": "1a87e88f7f3fa7e9ccfc4fbe8ec6928ce2f06d695abdb355a1b38a98f4ceb97b",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1675790451,
"kind": 1,
"tags": [
[
"e",
"3d36bf9009a0223baa45107fd4d1c13cff51a1fee133fb78fb2ac28df9b6852a",
"",
"root"
],
[
"e",
"b36e4109232637ea1bac0f237e77c22d2cc8462d7daaee8298eefbd6fbdc3fc1",
"",
"reply"
],
[
"p",
"aae9cfdb3113db442c1ad8d4c670a28091e5267748e71d2c1e189e423dbea1bf"
]
],
"content": " package main\n\nimport \"fmt\"\n\nfunc factorial(number int) int {\n\t// Base Case\n\tif number == 0 {\n\t\treturn 1\n\t}\n\n\t// Recursive Case\n\treturn number * factorial(number-1)\n}\n\nfunc main() {\n\tfmt.Println(\"Factorial of 4 is:\", factorial(4))\n}",
"sig": "fb98c3c8882770fa46ff84c52144f7e3db7b2df5e24aad78c54cc6c1c34dc7e15683c6a0b1104d32698a0b24a38766f657fd869c08271bc76f5df0d3030a30ee"
}