From e55dd276c4666318693736a5f80b77244c76b7a8 Mon Sep 17 00:00:00 2001 From: stephey <stephey> Date: Mon, 5 Apr 2010 18:27:05 +0000 Subject: [PATCH] Moved Prime Program into its own folder --- Robust/src/Tests/mlp/stephen/Test.java | 77 ------------------- Robust/src/Tests/mlp/stephen/Test.original | 65 ---------------- .../src/Tests/mlp/stephen/Test.workingSerial | 67 ---------------- 3 files changed, 209 deletions(-) delete mode 100755 Robust/src/Tests/mlp/stephen/Test.java delete mode 100644 Robust/src/Tests/mlp/stephen/Test.original delete mode 100755 Robust/src/Tests/mlp/stephen/Test.workingSerial diff --git a/Robust/src/Tests/mlp/stephen/Test.java b/Robust/src/Tests/mlp/stephen/Test.java deleted file mode 100755 index 409319ef..00000000 --- a/Robust/src/Tests/mlp/stephen/Test.java +++ /dev/null @@ -1,77 +0,0 @@ -public class Test -{ - //Apparently global variables are not yet supported - //private int MAX = 100000; - - public Test(){} - - public static void main(String args[]) { - - System.out.println("# it starts"); - Test t = new Test(); - t.doSomeWork(); - - } - - public void doSomeWork() - { - int MAX = 100000; - int ittr = 100; - - long sum = 0; - long time = System.currentTimeMillis(); - - //I did the for loop this way so that each parallel thread would take - //about the same time - for(int i = 0; i < MAX/2 + 1; i += ittr) - { - int innerSum = 0; - - sese a - { - for(int j = i; (j < i + ittr) && j < MAX/2 + 1; j++) - { - - int oppositeNum = MAX - j; - - if(isPrime(j)) - innerSum += j; - - if(i != oppositeNum && isPrime(oppositeNum)) - innerSum += oppositeNum; - } - } - - sese b - { - sum += innerSum; - } - } - - System.out.println("The sum of primes from 1 to " + MAX + " is " + sum + "."); - System.out.println("Note: 1 is counted as a prime."); - System.out.println("Time Consumed: " + (System.currentTimeMillis() - time) + " ms"); - - } - - - private boolean isPrime(int number) - { - //handles special cases - if(number < 1) - return false; - - if (number < 3) - return true; - - //Tests the rest of the numbers - for(int i = 2; i < number; i++) - { - if(number%i == 0) - return false; - } - - return true; - } - -} diff --git a/Robust/src/Tests/mlp/stephen/Test.original b/Robust/src/Tests/mlp/stephen/Test.original deleted file mode 100644 index d71d4b40..00000000 --- a/Robust/src/Tests/mlp/stephen/Test.original +++ /dev/null @@ -1,65 +0,0 @@ -public class Test -{ - private final int MAX = 100000; - - public Test(){} - - public static void main(String args[]) { - - System.out.println("# it starts"); - Test t = new Test(); - t.doSomeWork(); - - } - - public void doSomeWork() - { - long sum = 0; - long time = System.currentTimeMillis(); - - //I did the for loop this way so that each parallel thread would take - //about the same time - for(int i = 0; i < MAX/2 + 1; i++) - { - int innerSum = 0; - - { - int oppositeNum = MAX - i; - - if(isPrime(i)) - innerSum += i; - - if(i != oppositeNum && isPrime(oppositeNum)) - innerSum += oppositeNum; - } - - sum += innerSum; - } - - System.out.println("The sum of primes from 1 to " + MAX + " is " + sum + "."); - System.out.println("Note: 1 is counted as a prime."); - System.out.println("Time Consumed (Not Parallelized): " + (System.currentTimeMillis() - time) + " ms"); - - } - - - private boolean isPrime(int number) - { - //handles special cases - if(number < 1) - return false; - - if (number < 3) - return true; - - //Tests the rest of the numbers - for(int i = 2; i < number; i++) - { - if(number%i == 0) - return false; - } - - return true; - } - -} diff --git a/Robust/src/Tests/mlp/stephen/Test.workingSerial b/Robust/src/Tests/mlp/stephen/Test.workingSerial deleted file mode 100755 index 9802b4ea..00000000 --- a/Robust/src/Tests/mlp/stephen/Test.workingSerial +++ /dev/null @@ -1,67 +0,0 @@ -public class Test -{ - //Apparently global variables are not yet supported - //private int MAX = 100000; - - public Test(){} - - public static void main(String args[]) { - - System.out.println("# it starts"); - Test t = new Test(); - t.doSomeWork(); - - } - - public void doSomeWork() - { - int MAX = 100000; - long sum = 0; - long time = System.currentTimeMillis(); - - //I did the for loop this way so that each parallel thread would take - //about the same time - for(int i = 0; i < MAX/2 + 1; i++) - { - int innerSum = 0; - - { - int oppositeNum = MAX - i; - - if(isPrime(i)) - innerSum += i; - - if(i != oppositeNum && isPrime(oppositeNum)) - innerSum += oppositeNum; - } - - sum += innerSum; - } - - System.out.println("The sum of primes from 1 to " + MAX + " is " + sum + "."); - System.out.println("Note: 1 is counted as a prime."); - System.out.println("Time Consumed (Not Parallelized): " + (System.currentTimeMillis() - time) + " ms"); - - } - - - private boolean isPrime(int number) - { - //handles special cases - if(number < 1) - return false; - - if (number < 3) - return true; - - //Tests the rest of the numbers - for(int i = 2; i < number; i++) - { - if(number%i == 0) - return false; - } - - return true; - } - -} -- 2.34.1