Golang math/rand.Intn() function example
package math/rand
Golang math/rand.Intn() function usage example
package main
import (
"fmt"
"math/rand"
)
func main() {
n := 10
i := 0
for i < n {
x := rand.Intn(10)
fmt.Println(i, x)
i += 1
}
fmt.Println("i : ", i)
}
Reference :
Advertisement
Something interesting
Tutorials
+10.7k Golang : Get currencies exchange rates example
+9.2k Golang : Create and shuffle deck of cards example
+17.9k Golang : Login and logout a user after password verification and redirect example
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+14.3k Golang : Recombine chunked files example
+11.4k Golang : Concatenate (combine) buffer data example
+9.1k Golang : Gonum standard normal random numbers example
+14.3k Golang : How to shuffle elements in array or slice?
+8.2k Golang : Find relative luminance or color brightness
+15.9k Golang : Get current time from the Internet time server(ntp) example
+7.3k Golang : Not able to grep log.Println() output
+5k Golang : Calculate a pip value and distance to target profit example