13-loops/questions/02-randomization.md
1: Computers are deterministic machines. They can't generate truly random numbers (unlike actual physical processes).
1: Right. The square-brace means: "inclusion". The parenthesis means: "exclusion". So, [0, 5] means: 0, 1, 2, 3, 4. It's called the "mathematical interval notation".
rand.Intn(0)
1: That's not the cause of this error. You don't always have to seed it. 2: No, it does not.
Note that, each seed number below returns pseudorandom numbers as these:
Seed: 0
3 3 6 8 4 1 9 3 6 6
Seed: 1
1 1 9 3 2 4 7 6 6 6
Seed: 2
10 1 2 2 0 6 4 1 0 5
Here's the program:
package main
import (
"fmt"
"math/rand"
)
func main() {
for i := 0; i < 3; i++ {
rand.Seed(int64(i))
fmt.Print(rand.Intn(11), " ")
fmt.Print(rand.Intn(11), " ")
}
}
4: The numbers are determined depending on the seed number. So, this loop, seeds the pseudorandom generator with 0, 1, and 2 respectively.
And, after each seed, it calls Intn twice to generate two random numbers.
So, if you look at the result, 3 3 is the first two numbers of Seed: 0. 1 1 for Seed: 1. And, 10 1 for Seed: 2.