Advertisement
Guest User

class Generatior

a guest
Oct 1st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.io.FileWriter;
  2. import java.io.IOException;
  3. import java.math.BigInteger;
  4.  
  5. public class Generator {
  6.     //Ниже реализован линейный конгруэнтный метод ГПСЧ
  7.     //В качестве модуля берется большое простое число
  8.     private int m = /*8191*/89;
  9.     private int a = 5;
  10.     private int c = 3;
  11.     public int x;
  12.  
  13.     public Generator(int x) {
  14.         this.x = x%m;
  15.     }
  16. //Для избавления от закономерности с четными/нечетными числами проводится битовый сдвиг влево
  17.     public int generate () {
  18.         x = (a*x + c)%m;
  19.         return x;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement