Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Prime function
- void* Prime(void* index){
- int temp_index;
- temp_index = *((int*)index);
- long sum_t = 0;
- for(long i = start_numbers[temp_index]; i <= numbers[temp_index]; i++){
- // Corner cases
- if(i<=1)continue;
- if (i <= 3){
- sum_t++;
- continue;
- }
- for (int j=2; j*j <= i; j++)
- {
- if ((i % j == 0) || (i %( j+2))==0 )
- {
- break;
- }
- else if (j+1 > sqrt(i)) {
- sum_t++;
- }
- }
- }
- cout << "Thread " << temp_index << " terminates" << endl;
- pthread_exit( (void*) sum_t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement