I'm trying to Implement types of primes in my program. In one of the type Exponent Of Mersenne, the formula to calculate is (2 power P) -1 Here P is Prime. and check the output is prime.
In calculating, I'm able to get the power but while checking for prime, the process is Hanging . and if I leave it for a very long long time then it is being calculated.
example would be, (2 power 10090) -1 and calculate if this is prime
I'm using Big Integer
I'musing this code
int prime1 = CalculatePrime(n);
BigInteger powerPrime = BigInteger.Pow(2, prime1);
bool isPrime = CheckPrime(powerPrime - 1);
private bool CheckPrime(BigInteger num)
{
    if (num == 0 || num == 1) 
        return false;
    bool isPrime = true;
    for (int j = 2; j < num; j++)
    {
        if ((num % j) == 0)
        {
            isPrime = false;
            break;
        }
    }
    return isPrime;
}
How would be this - http://www.dotnetperls.com/prime