Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         foo();
  4.     }
  5.  
  6.  
  7.     static void foo() {
  8.         int src = getProperRand();
  9.         System.out.println("scr = " + src);
  10.  
  11.         int dst = getProperRand();
  12.         int count = 1;
  13.         while (src != dst){
  14.             dst = getProperRand();
  15.             count++;
  16.         }
  17.  
  18.         System.out.println("count = " + count);
  19.     }
  20.  
  21.     static int getProperRand() {
  22.         int rand = new Random().nextInt(10_000_000);
  23.         int l = 1_000_000;
  24.         return l + rand;
  25.     }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement