You are on page 1of 1

#include<stdio.

h>
#include<time.h>

int main(){
clock_t start= clock();
int x,y;
int n=500000; //lmite superior del rango
int arr[ n ];
for ( x = 2; x <= n; x++ )
if ( arr[ x ] != 0 ) //S el nmero es primo

for ( y = (x+x); y <n; y += x )


arr[ y ] = 0; // Entonces, se eliminan sus mltiplos.

for(x=2;x<=n;x++)
if(arr[x]!=0)
printf("%d,",x);
printf("Tiempo transcurrido: %f", ((double)clock() - start) /CLOCKS_PER_SEC);
return 0;

You might also like