Advertisement
Guest User

Congruence

a guest
Nov 12th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. package edu.tfzr.nemanja;
  2.  
  3. import java.math.BigInteger;
  4.  
  5. public class Congruence {
  6.     public BigInteger multiplier;
  7.     public BigInteger modulus;
  8.     public BigInteger seed;
  9.     private BigInteger x; //next value
  10.    
  11.     public static int count=0;
  12.    
  13.     public Congruence(String smultiplier, String smodulus, String sseed) {
  14.         multiplier = new BigInteger(smultiplier);
  15.         modulus = new BigInteger(smodulus);
  16.         seed = new BigInteger(sseed);
  17.         x = seed;
  18.         //System.out.println("k:" + k + " , m: " + ", s: " +s);
  19.     }
  20.     public BigInteger nextValue() {
  21.         x = (multiplier.multiply(x)).mod(modulus);
  22.         return x;
  23.     }
  24.     public double doubleValue() {
  25.         return (x.doubleValue()) / (modulus.doubleValue());
  26.     }
  27.    
  28.    
  29.    
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement