This question was inspired by some code where someone decided that they wanted to make their "rand" more random by using it as a seed for itself:
rand(rand(rand(time()))
Obviously, that doesn't work. But my question is, what happens if you take that to the extreme, and just keep feeding the output back into the input.
Do you end up with a particular value all the time? Is it 0? Does it depend on the initial seed? Is there a particular repeating pattern? Or a non-repeating pattern like the digits of pi?
I assume it's going to depend on which random function is being used, and likely varies by programming language. So what happens for the most popular random functions?
Aucun commentaire:
Enregistrer un commentaire