When i do like this, it works well in my code...
...
for (i = 2; i <= sqrt(500000); i++)
...
But do like
for (i = 2; i < sqrt(500000) + 1; i++)
executes after compile, error occurs saying Segmentation fault (core dumped)
.
for loop body
is:
for (i = 2; i <= sqrt(500000); i++) {
summation[i * i] += i;
for (j = i + 1; j <= 500000 / i; j++) {
summation[i * j] += (i + j);
}
}
Is there any difference between the two for loops? Thanks