[?] [X] [Torrents]

Not logged in.


Detailed module view [disabled]
Home

Giygas's Profile

About

Profile Picture

Profile

#include <stdio.h>
#include <stdlib.h>
int main() {
#define LONG unsigned long long
LONG lower_bound;
LONG upper_bound;
scanf( "%llu %llu", &lower_bound, &upper_bound );
upper_bound += 1;

unsigned int* isprime = malloc( ( upper_bound - lower_bound - 1 ) / 8 + 4 );
for ( LONG i = 0; i <= ( upper_bound - lower_bound ) / 32; ++i ) {
isprime[ i ] = 0;
}

#define MAX(A, B) ( (A) * ( (A) >= (B) ) + (B) * ( (A) < (B) ) )
for ( LONG i = 2; i < ( upper_bound + i - 1 ) / i; ++i ) {
for ( LONG u = MAX( i, ( lower_bound + i - 1 ) / i ); u < ( upper_bound + i - 1 ) / i; ++u ) {
isprime[ ( i * u - lower_bound ) / 32 ] |= ( 1 << ( ( i * u - lower_bound ) % 32 ) );
}
}

return 0;

printf( "CALCULATION OVER" );
LONG indent_count = 0;
for ( LONG i = 0; i < upper_bound - lower_bound; ++i ) {
if ( ( isprime[ i / 32 ] & ( 1 << ( i % 32 ) ) ) == 0 ) {
if ( indent_count++ % 10 == 0 ) {
printf( "n%llu ", i + lower_bound );
} else {
printf( "%llu ", i + lower_bound );
}
}
}

upper_bound -= 1;
printf( "nfrom %llu to %llu there were %llu primesn", lower_bound, upper_bound, indent_count );

free( isprime );
return 0;
}

Giygas's messages

Last 10 messages:
From: Viraxor
15:01 on 19th February 2025
Viraxor

Your reviews are great! Very detailed and nicely written.


Messages View full Messages