-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
43 lines (34 loc) · 811 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
clock_t start, end;
start = clock();
int numeros[24998];
int insert;
for(int i=2;i < 25000;i++){
if(i != 0 && i != 1){
numeros[insert] = i;
insert = insert +1;
}
}
int s = ( sizeof(numeros) / sizeof(numeros[0]) );
int primo[2762] = {};
int count = 0;
for(int n=0;n < s;n++){
int mult = 0;
for(int j=2;j < numeros[n]+1;j++){
if(numeros[n] % j == 0){
mult = mult +1;
}
}
if(mult <= 1){
primo[count] = numeros[n];
count++;
}
}
end = clock();
double total_time = (end - start)/CLOCKS_PER_SEC;
printf("%f\n", total_time);
return 0;
}