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
last reply
- 1
reply
- 91
views
- 2
users