Skip to content

Instantly share code, notes, and snippets.

@podanypepa
Created December 18, 2019 10:52
Show Gist options
  • Save podanypepa/56d08d289c691edaa449f8a7918981da to your computer and use it in GitHub Desktop.
Save podanypepa/56d08d289c691edaa449f8a7918981da to your computer and use it in GitHub Desktop.
fak func
‎‎​package main
import (
"fmt"
"os"
"strconv"
)
func fak(n int) int {
if n == 1 {
return n
}
return n + fak(n-1)
}
func main() {
if len(os.Args) < 2 {
os.Exit(1)
}
n, _ := strconv.Atoi(os.Args[1])
fmt.Printf("%d: %d\n", n, fak(n))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment