I'm learning some Go and I'm doing some interview exercises. I have one exercice where one is asked to perform some operation randomly with a 1 in a million probability.
Let's say that I want to return true
once in a million.
If my math is still right (and Google too), I would calculate this with the expression math.Pow(1-(1/1000000),1000000)
however this keeps returning me 1
constantly, which doesn't seem correct.
Given this description, how could I ensure that I'd return true
only once in a million? This sounds trivial but I'm really struggling with it.