@@ -0,0 +1,2183 @@
+package thirty_days_of_code;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * In this challenge, you will determine if a given number X is prime or not. A%0D%0A * prime number is a natural number greater than 1 that has no positive divisors%0D%0A * other than 1 and itself. You will be given N numbers and for each, you will%0D%0A * print out %22Prime%22 if the number is prime or %22Not prime%22 if the number is not%0D%0A * prime.%0D%0A * %0D%0A * If this is too easy, create a method that decides if X is prime or not in%0D%0A * O(sqrt(X)) time. Think modulos and square root! If you are having trouble, try%0D%0A * creating an O(X) time algorithm and see whether it solves the problem or not.%0D%0A * %0D%0A * To review Big-O Notation, remember...%0D%0A * %0D%0A * Big-O is used in Computer Science to describe the performance or complexity of an algorithm.%22%0D%0A * Big-O specifically describes the worst-case scenario, and can be used to describe%0D%0A * the execution time required or the space used (e.g. in memory or on disk) by an algorithm.%22%0D%0A * %0D%0A * Input Format: %0D%0A * The first line of the input is T, total number of test cases. Each of the%0D%0A * next line contains an integer N.%0D%0A * %0D%0A * Constraints: %0D%0A * 1 %3C= T %3C= 20%0D%0A * 1 %3C= N %3C= 2x10%5E9%0D%0A * %0D%0A * Output Format: %0D%0A * For each test case print Prime if N is prime, otherwise print Not prime.%0D%0A * %0D%0A * Sample Input: %0D%0A * 3%0D%0A * 12%0D%0A * 5%0D%0A * 7%0D%0A * %0D%0A * Sample Output: %0D%0A * Not prime%0D%0A * Prime%0D%0A * Prime%0D%0A */%0D%0Apublic class RunningTimeAndComplexity %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) %7B%0D%0A        Scanner sc = new Scanner(System.in);%0D%0A        %0D%0A        int numCases = sc.nextInt();%0D%0A        %0D%0A        for (int i = 0; i %3C numCases; i++) %7B%0D%0A            System.out.println(checkPrime(sc.nextInt()));%0D%0A        %7D%0D%0A        sc.close();%0D%0A    %7D%0D%0A    %0D%0A    static String checkPrime(int num) %7B%0D%0A        boolean isPrime = true;%0D%0A        %0D%0A        primeCheckLoop:%0D%0A        for (int i = 2; i * i %3C num; i++) %7B%0D%0A            if ((num %25 i) == 0) %7B%0D%0A                isPrime = false;%0D%0A                break primeCheckLoop;%0D%0A            %7D%0D%0A        %7D%0D%0A        if (num %3E 1 && isPrime) %7B%0D%0A            return %22Prime%22;%0D%0A        %7D else %7B%0D%0A            return %22Not prime%22;%0D%0A        %7D%0D%0A    %7D%0D%0A%7D

Add RunningTimeAndComplexity