Closed
Description
In src/math/rand/rand.go
, there is the following code:
func (r *Rand) Perm(n int) []int {
m := make([]int, n)
for i := 0; i < n; i++ {
j := r.Intn(i + 1)
m[i] = m[j]
m[j] = i
}
return m
}
i
can start from 1
instead of 0
since the iteration for i=0
always swap m[0]
with m[0]
. A fix is to change i := 0
to i := 1
.