MCPcopy Create free account
hub / github.com/0xAX/go-algorithms / RandArray

Function RandArray

utils.go:8–17  ·  view source on GitHub ↗
(n int)

Source from the content-addressed store, hash-verified

6)
7
8func RandArray(n int) []int {
9 // needed a seed input else it will generate the same number
10 rand.Seed(time.Now().UnixNano())
11
12 arr := make([]int, n)
13 for i := 0; i <= n-1; i++ {
14 arr[i] = rand.Intn(n)
15 }
16 return arr
17}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected