fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int n = 8;
  13. final Random rnd = new Random();
  14. int lastlast = rnd.nextInt(n);
  15. int last = (lastlast + 1 + rnd.nextInt(n - 1)) % n;
  16. for (int i = 0; i < 30; i++) {
  17. int r = (lastlast + 1 + rnd.nextInt(n - 2)) % n;
  18. if (r == last)
  19. r = (lastlast + n - 1) % n;
  20. lastlast = last;
  21. last = r;
  22. System.out.println(last);
  23. }
  24. }
  25. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
3
7
5
3
2
7
6
0
3
2
5
0
6
2
5
6
1
3
7
0
4
7
0
1
5
7
0
4
5
2