Skip to content

Instantly share code, notes, and snippets.

@cr0sh
Created April 17, 2016 17:18
Show Gist options
  • Save cr0sh/0b90983d594819b91189c6116da1a35f to your computer and use it in GitHub Desktop.
Save cr0sh/0b90983d594819b91189c6116da1a35f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io/ioutil"
"math/big"
"os"
"strconv"
"time"
)
func main() {
n, err := strconv.ParseInt(os.Args[1], 10, 64)
if err != nil {
panic(err)
}
r := big.NewInt(1)
start := time.Now()
for i := int64(2); i <= n; i++ {
r.Mul(r, big.NewInt(i))
}
fmt.Println("Elapsed:", time.Since(start))
fmt.Println(r)
ioutil.WriteFile("result.txt", []byte(r.String()), 0644)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment