Random number generator problem

Question

Hints

Answer