@@ -0,0 +1,1336 @@
+import java.util.Scanner;%0A%0A/**%0A * This program finds the smallest non-prime number generated by the formula%0A * y = x%5E2 - x + 41.%0A **/%0Apublic class Prime_Formula %7B%0A    // This is a very inefficient, but easy to write prime check algorithm%0A    public static boolean check_If_Prime(int p) %7B%0A        int i = 2;%0A        boolean m = true;%0A%0A        // If the number is 1 or 0, it's not prime%0A        if (p == 1 %7C%7C p == 0) %7B%0A            return false;%0A        %7D else %7B%0A            while (i %3C p && m == true) %7B%0A                // If the number has a factor, it isn't prime%0A                if (p %25 i == 0) %7B%0A                    m = false;%0A                %7D else %7B%0A                     i++;%0A                %7D%0A            %7D%0A            return m;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(%22Prime Generating Formula%22);%0A        int x = 0, y;%0A        boolean flag = true;%0A%0A        // if and while require boolean statements as their arguments.%0A        // Boolean variables, however, also work, e.g.,%0A        // while (flag == true) %7B%0A        while (flag) %7B%0A            y = (x * x) - x + 41;%0A            if (check_If_Prime(y)) %7B%0A                x++;%0A            %7D else %7B%0A                flag = false;%0A            %7D%0A        %7D%0A        System.out.println(%22The value of x when y is non-prime is %22 + x);%0A    %7D%0A%7D%0A

Add problem 8 to unit 2