Implement random number generator