Created
July 21, 2020 03:28
-
-
Save sureshsarda/e8c13f5ee858d55b41d9f542a2e24eb8 to your computer and use it in GitHub Desktop.
Transforming a random number generator to another scale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RandomTransformer { | |
private int lastReturned = 0; | |
public int rand10() { | |
lastReturned = ((lastReturned + rand7()) % 10) + 1; | |
return lastReturned; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment