public void GeneratePrime(int n)
    {
        if(!Prime.isEmpty())
        {
            Prime.clear();
        }
        PrimeTable = new long[n];
        PrimeTable[0] = NO_PRIME;
        PrimeTable[1] = NO_PRIME;
        PrimeTable[2] = PRIME;
        Prime.add(2);
        int limit = (int)(Math.sqrt(n));
        for(int i = 4; i < n; i += 2)
        {
            PrimeTable[i] = NO_PRIME;
        }
        for(int i = 3; i <= limit; i += 2)
        {
            if(PrimeTable[i] == PRIME)
            {
                Prime.add(i);
                for(int j = i*i; j < n; j += i)
                {
                    PrimeTable[j] = NO_PRIME;
                }
            }
        }
        int new_limit = limit + 1;
        if((new_limit & 1) == 0)
        {
            new_limit++;
        }
        for(int i = new_limit; i < n; i += 2)
        {
            if(PrimeTable[i] == PRIME)
            {
                Prime.add(i);
            }
        }
    }