I'm trying to use a sieve but this line is not working, it throws a SIGSEGV error.

bool * pm = new bool[max];

long max = 10000001;
bool * pm = new bool[max];
	pm[0] = false;
	pm[1] = false;
    for (long i = 2; i * i < max; i++)
{
    if (pm[i])
    {
        for (long j = i * i; j < max; j += i)
        {
            pm[j] = false;
        }
    }
}

I'm lost, why the error??, thanks!!.

  • created

    Nov '09
  • last reply

    Dec '09
  • 1

    reply

  • 91

    views

  • 2

    users