Solution for the random numbers problem