Skip to content

Implementationg of sieve of eratosthenes in mojo

Notifications You must be signed in to change notification settings

HostServer001/soe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Prime Number Finder (Sieve of Eratosthenes)

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.

Features

  • 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.

Usage

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

Repo Structure

.
├── README.md
├── soe_parallel
└── soe_parallel.mojo

1 directory, 3 files

Example Output

./soe 10
2
3
5
7
Total prime number: 4
Elapsed: 31220

Functions

  • 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.

About

Implementationg of sieve of eratosthenes in mojo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages