@@ -0,0 +1,600 @@
+// Answer to Module 2 Mastery Check No. 10%0A// Based on algorithm introduced here: http://www.stoimen.com/blog/2012/05/08/computer-algorithms-determine-if-a-number-is-prime/%0Aclass PrimalityTest %7B%0A%09public static void main(String args%5B%5D) %7B%0A%09%09int count, p;%0A%09%09bool check = true;%0A%09%09%0A%09%09for(p = 2; p %3C= 100; p++) %7B%0A%09%09%09for(count = p; (count %3C= (int) Math.sqrt(p)) && check; count++) %7B%0A%09%09%09%09if(p %25 count == 0) %7B%0A%09%09%09%09%09check = false;%0A%09%09%09%09%09System.out.println(p + %22 = %22 + count + %22 * %22 + (p / count) + %22, so p is not prime.%22);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09if(check)%0A%09%09%09%09System.out.println(p + %22 is a prime number!%22);%0A%09%09%7D%0A%09%7D%0A%7D%0A

test if a number is prime