commit 4c8e649c0306fef4fc347a690c1aa68ed2ae1e11
parent 66efb4094768a7b776fce15561dae1fc0c774e8d
Author: mjkloeckner <martinjkloeckner@gmail.com>
Date: Thu, 21 Mar 2024 00:01:32 -0300
Set 0 and 1 as non prime manually
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tps/1/main.cpp b/tps/1/main.cpp
@@ -15,12 +15,13 @@ int main (void) {
unsigned long ti, i, j;
double tt;
std::ofstream fp;
+ std::vector<bool> numeros(MAXIMO, true);
ti = clock();
- std::vector<bool> numeros(MAXIMO, true);
+ numeros[0] = numeros[1] = false; // 0 y 1 no son primos
for (i = 2; i < std::sqrt(MAXIMO); ++i) {
- if(numeros[i] == true) {
+ if(numeros[i]) {
for (j = i; j <= (MAXIMO/i); ++j) {
numeros[i*j] = false;
}
@@ -41,7 +42,6 @@ int main (void) {
}
fp.close();
-
tt = (double(clock() - ti)) / CLOCKS_PER_SEC;
std::cout.precision(2);