class ChallengeOne {

    public static void main(String[] args) {

        /**** Variable Declarations ****/
        boolean divisibleByThree = false;
        boolean divisibleByEight = false;
        boolean isPrime = false;
        int divisionCounter = 0;

        /**** Loop through from 1 to 2500 ****/
        for (int i = 1; i <= 2500; i++) {

            //Check for divisibilty. Use boolean flags to record result.
            if (i % 3 == 0) {
                divisibleByThree = true;
            } else {
                divisibleByThree = false;
            }

            if (i % 8 == 0) {
                divisibleByEight = true;
            } else {
                divisibleByEight = false;
            }

            //Horribly inefficient prime calculator. Brute-force every possible division.
            for (int j = 1; j < i; j++) {
                if (i % j == 0) {
                    divisionCounter++;
                }
            }

            //Should only be divisible by 1, so divCount should = 1
            if (divisionCounter == 1) {
                isPrime = true;
            }

            //Check for the requirements.
            if (isPrime == true || ((divisibleByThree == true && divisibleByEight == false) || (divisibleByThree == false && divisibleByEight == true))) {
                System.out.println(i);
            }

            //reset values for next iteration
            divisibleByThree = false;
            divisibleByEight = false;
            isPrime = false;
            divisionCounter = 0;
        }
    }
}