go-play / fact.go

package main

import (
	"flag"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func fact(n int64) *big.Int {

	f := big.NewInt(0)
	f.MulRange(1, n)

	return f

}

func main() {
	flag.Parse()

	if flag.NArg() != 1 {
		fmt.Println("error: wrong number of arguments")
		os.Exit(1)
	}

	n, err := strconv.ParseInt(flag.Arg(0), 10, 64)
	if err != nil {
		fmt.Println("error: bad number -", flag.Arg(0))
		os.Exit(1)
	}
	fmt.Println(fact(n))
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.