(Java)Faster than the editorial fastest code


#1
static int isPrime(int A) {
    if (A <= 3)
        return A > 1 ? 1 : 0;

    if (A % 2 == 0 || A % 3 == 0)
        return 0;

    int i = 5;
    int limit = (int)Math.sqrt(A);
    while (i <= limit) {
        if (A % i == 0 || A % (i + 2) == 0)
            return 0;
        i += 6;
    }
    return 1;
}