// primes.c // Řešení IJC-DU1, příklad a), 22.3.2024 // Autor: Roman Nečas, FIT // Přeloženo: gcc 13.2.1 #include "primes.h" #include #include #define N 666000000 int main() { clock_t start = clock(); bitset_create(name, N); Eratosthenes(name); // Saves last 10 primes bitset_index_t primes[10] = {0, }; int count = 0; for (bitset_index_t i = bitset_size(name)-1; count < 10 && i > 0; i--) { if (bitset_getbit(name, i)) { primes[9 - count++] = i; } } //Writes last 10 primes for (unsigned int i = 0; i < 10; i++) { printf("%lu\n", primes[i]); } fprintf(stderr, "Time=%.3g\n", (double)(clock() - start) / CLOCKS_PER_SEC); return 0; }