generates a random integer based on a parameter