You are on page 1of 2

Nombre: Unv: Dayver Vale Javier

Docente: Ing. Juan Pablo Luna


Fecha: 20 Septiembre 2018

HARDWARE Y PROGRAMACION BAJO NIVEL Unv: Dayver vale


NUMEROS PRIMOS CON EL NETODO DE CRIBA DE ERATÓSTENES

#include<stdio.h>

#include <time.h>

int criba() {

int N ;

scanf("%i",&N);

int i, j, nums[N+1], x = 1;

puts("\n\tSon PRIMOS:\n");

printf( "\t%5d\n", 2 );

for( i = 3; i <= N; i += 2 )

if( nums[i] != 1 ) {

printf( "\t%5d\n",i);

for( j = 2; ( i * j ) <= N; j++)

nums[i * j] = 1;

printf("\n Hasta %d hay %d numeros primos\n",N, --x);

int main(int argc, char *argv[]){

clock_t t_inicio , t_final;

double seg;

t_inicio=clock();

criba();

t_final=clock();

seg=(double)(t_final-t_inicio)/CLOCKS_PER_SEC;

printf ("\ntiempo =%.16g milisegunodos\n",seg*1000.0);

return (0);

HARDWARE Y PROGRAMACION BAJO NIVEL Unv: Dayver vale

You might also like