Created
August 10, 2011 10:40
-
-
Save ecylmz/1136533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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