Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created August 10, 2011 10:40
Show Gist options
  • Save ecylmz/1136533 to your computer and use it in GitHub Desktop.
Save ecylmz/1136533 to your computer and use it in GitHub Desktop.
package main
import (
"big"
"fmt"
)
func fak(i int64) *big.Int {
if i < 0 {
return nil
}
r := big.NewInt(1)
var f big.Int
for k := int64(2); k <= i; k++ {
r.Mul(r, f.SetInt64(k))
}
return r
}
func fak1(i int64) *big.Int {
var z big.Int
return z.MulRange(1, i)
}
func main() {
fmt.Println(fak(5))
fmt.Println(fak1(6))
}
package main
import (
"fmt"
"rand"
"time"
)
func main() {
rand.Seed(time.Seconds())
fmt.Println(rand.Int())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment