This repo implements the Sieve of Eratosthenes algorithm to efficiently find all prime numbers up to a given integer n. It also measures the execution time using high‑precision nanosecond counters.
- Uses the classic Sieve of Eratosthenes to mark non‑prime numbers.
- Prints all prime numbers up to
n. - Displays the total count of prime numbers found.
- Reports elapsed execution time in nanoseconds.
Run the program from the command line with a single integer argument:
- 1
git clone https://github.com/HostServer001/soe- 2
cd soe- 3
./soe_parallel 10
This excutabel is only for linux system.
If the excutabel dosen't work on your system then install mojo.
And build the excutable for you device by mojo build seo_parallel.mojo
[OR]
You can also just run the mojo code using mojo seo_parallel.mojo 10
.
├── README.md
├── soe_parallel
└── soe_parallel.mojo
1 directory, 3 files
./soe 102
3
5
7
Total prime number: 4
Elapsed: 31220
- main(): Entry point, parses input and measures runtime.
- seo_loop(n): Core sieve algorithm, prints primes and their count.
- build_bool_list(n): Initializes a boolean list for marking primes.
- build_num_list(n): Generates the list of numbers from 2 to
n.