Created
November 4, 2017 07:21
-
-
Save visparashar/b027476e14f98608f13ff19890e34956 to your computer and use it in GitHub Desktop.
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
public class RandomGenerator { | |
public static void main(String[] args) { | |
// for getting 50% probability of 0 and 1 | |
System.out.println("For 50% of 0 and 1 probability "+random50()); | |
// for getting 75% probability of 1 | |
System.out.println("For getting 75% probability of 1 as output :"+random75()); | |
} | |
public static int random50() { | |
if(Math.random() <0.5) | |
return 1; | |
return 0; | |
} | |
public static int random75() { | |
return random50() | random50(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment