Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LCG {
- long a;
- long c;
- long m;
- long seed;
- long shift;
- public LCG(long _a, long _c, long _m, long seed) {
- this.a = _a;
- this.c = _c;
- this.m = _m;
- this.seed = seed;
- }
- public LCG(long _a, long _c, long _m, long seed, long _shift) {
- this.a = _a;
- this.c = _c;
- this.m = _m;
- this.seed = seed;
- this.shift = _shift;
- }
- public long next() {
- long x = (a*this.seed+c)%m ;
- if (x < 0)
- x= x+m;
- System.out.println(x);
- seed(x);
- x = (x >> this.shift);
- return x;
- }
- public void seed(long seed) {
- this.seed = seed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement