package com.hypirion.primes;

public final class Primes {

}

@@ -27,35 +27,1558 @@
 s;%0A%0A
-public final class Primes %7B%0A
+import java.util.List;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0A%0Apublic final class Primes %7B%0A    private static ArrayList%3CInteger%3E primeList = new ArrayList%3CInteger%3E%0A        (Arrays.asList(new Integer%5B%5D%7B2, 3, 5, 7, 11%7D));%0A%0A    public static List%3CInteger%3E takeUnder(int n)%7B%0A        createAllUnder(n);%0A        int i = Collections.binarySearch(primeList, n);%0A        if (i %3C 0)%0A            i = ~i;%0A        return take(i);%0A    %7D%0A%0A    public static List%3CInteger%3E take(int n)%7B%0A        ensureExists(n);%0A        return Collections.unmodifiableList(primeList.subList(0, n));%0A    %7D%0A%0A    public static int get(int n)%7B%0A        ensureExists(n);%0A        return primeList.get(n);%0A    %7D%0A%0A    public static boolean isPrime(long n)%7B%0A        if (n == 1)%0A            return false;%0A%0A        int sqrt = (int) Math.sqrt(n);%0A        createAllUnder(sqrt+1);%0A%0A        for (int prime : primeList)%7B%0A            if (sqrt %3C prime)%0A                break;%0A            else if (n %25 prime == 0)%0A                return false;%0A        %7D%0A%0A        return true;%0A    %7D%0A%0A    private static void ensureExists(int n)%7B%0A        for (int i = primeList.size(); i %3C= n; i++)%0A            addPrime();%0A    %7D%0A%0A    private static void createAllUnder(int n)%7B%0A        while (primeList.get(primeList.size() -1) %3C n)%0A            addPrime();%0A    %7D%0A%0A    private static void addPrime()%7B%0A        int possiblePrime = primeList.get(primeList.size() - 1);%0A%0A        do possiblePrime += 2;%0A        while (!isPrime(possiblePrime));%0A%0A        primeList.add(possiblePrime);%0A    %7D
 %0A%7D%0A

Implement basic prime generator.