daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Mar 19th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package matrixMultiplication.Prime;
  2.  
  3. public class ModularOperations {
  4.     public static void main(String[] args) {
  5.         double initialTime = System.currentTimeMillis();
  6.         ModularOperations op = new ModularOperations();
  7.  
  8.         for (int i = 0; i < 10000; i++) {
  9.             long prime = op.generatePrimeSeeded(i);
  10.             System.out.println(prime);
  11.         }
  12.  
  13.         double finalTime = System.currentTimeMillis();
  14.         System.out.println(finalTime - initialTime);
  15.     }
  16.  
  17.     public long generatePrimeSeeded(int seed) {
  18.         int num = (int) (Math.pow(seed * Math.random(), 10 * Math.random()) * Math.random() * Math.random() * 10);
  19.         if (num > 1) {
  20.             for (int i = 1; i < num && num > 1; i++) {
  21.                 if (calculateGCD(num, i) > 1) {
  22.                     return generatePrimeSeeded(seed);
  23.                 }
  24.             }
  25.             return num;
  26.         }
  27.         return generatePrimeSeeded(seed);
  28.     }
  29.  
  30.     private int calculateGCD(int a, int b) {
  31.         if (b == 0)
  32.             return b;
  33.         return calculateGCD(b, a % b);
  34.     }
  35. }
RAW Paste Data
Top