private static String listAllPrimeNumbersForGivenRange(int range) {

        StringBuffer primeStr = new StringBuffer();

        // set all values for the array to true
        boolean[] primes = new boolean[range];
        Arrays.fill(primes, true);

        // prime number must be greater than 1, therefore int is assigned the starting value of 2.
        for (int i = 2; i < range; i++) {

            for (int j = 2; i * j < primes.length; j++) {
                primes[i * j] = false;

            }

            if(primes[i]) {
                primeStr.append(i + ", ");
            }

        }

        return primeStr.toString();
    }