Project Euler #3 - checking only up to sqrt(input)
This implementation is not correct: for your example 14 it incorrectly returns 2 instead of 7.

You don't need to check == true of boolean expressions, you can use them directly, for example:

if (numbers[count]) { ... }


The formatting doesn't follow Java standards. In Eclipse, if you select your function and press Control-Shift-f it will change it this, which is more pleasant to read:

public static int largestPrime(long n) {
    int limit = (int) Math.sqrt(n) + 1;
    boolean[] numbers = new boolean[limit];
    Arrays.fill(numbers, true);
    int largestPrimeFactor = 1;
    for (int count = 2; count &lt; limit; count++) {
        if (numbers[count]) {
            for (int i = 2; i * count &lt; limit; i++) {
                numbers[count * i] = false;
            }
            if (n % count == 0) {
                largestPrimeFactor = count;
            }
        }
    }
    return largestPrimeFactor;
}


A simple way to fix the implementation is to re-implement following the same logic you do in math class:


Start from d = 2
Divide the target number by d as many times as possible without remainder
Increment d, return to step 2, until target is reduced to 1


This is pretty simple, correct, without using a boolean array:

public static long largestPrimeFactor(long n) {
    long d = 2;
    long target = n;
    while (target &gt; 1) {
        while (target % d == 0) {
            target /= d;
        }
        ++d;
    }
    return d - 1;
}


To make this faster, after the ++d you can insert this check:

        if (d * d &gt; target) {
            return target;
        }