c - Error: Exited: ExitFailure 45 -


i tried solve project euler's 10th question using somewhat-optimized algorithm finding prime numners

#include<stdio.h> #include<math.h>  long long int main() {     int flag =1;     long int lim = 199999; //upto prime generated     long int purposedprime = 2;     long int primeset[200000] = {0}, count=0;      long int i;     float sroot_pp;     long long int sum = 0 ; //this prj_euler :)     primeset[count] = 2; count++; purposedprime++;     primeset[count] = purposedprime ; count++;     sum = 5 ;     while(purposedprime < lim){         flag = 1;         purposedprime += 2;         sroot_pp = sqrt(purposedprime);         for(i=0; i<count; i++){             if(primeset[i]>sroot_pp) break;             if(purposedprime % primeset[i] == 0){ flag = 0; break;}         }         if(flag == 1){             primeset[count] = purposedprime ;             count++;             sum += purposedprime;         }     }      printf("total count: %d", count);      printf("\n");     printf("sum : %ld", sum);     return sum; } 

i ran in local machine: codeblocks mingw in win8. output

total count: 17984 sum : 1709600813 process returned 7096800813 (0x65e6702d) execution time : 0.063 s press key continue 

i ran in codepad . output

total count: 17984 sum : 1709600813 exited: exitfailure 45 

in both cases output incorrect. think has error shown. error pointing to?

the error pointing returning non-zero value main function. fix error, replace return sum return 0. won't results, though. similarly, i'd change return value of main int, won't make difference, either.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -