Source

go-play / fact.go

Full commit
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))
}