TUTTO è forza bruta xD

A quale parte ti riferivi?

Questa?
codice:
bool IsPrime(long n)
{
    //Sets the maximum factor to be tested
    //as the square root of the number
    long limit = (long)(sqrt(n) + 1);

    for (int i = 2; i < limit; i++)
        if ((n % i) == 0) return false;

    return true;
}
O questa?
codice:
//Finds next prime factor
        do
        {
            factor++;
        }
        while (!IsPrime(factor));