LoginSignup
40
30

More than 5 years have passed since last update.

Goで乱数

Last updated at Posted at 2013-08-25
rand.go
package main

import (
        "fmt"
        "math/rand"
        "time"
)

func main() {
        rand.Seed(time.Now().UnixNano())
        fmt.Println("random number is", rand.Intn(15))
}
$ go run rand.go
5
$ go run rand.go
12
$ go run rand.go
0
$
40
30
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
40
30