Giter Club home page Giter Club logo

sieve-of-eratosthenes's Introduction

Sieve-of-Eratosthenes

About

  • The Sieve of Eratosthenes is an alternative method to find the number of prime numbers in a a given range.
  • It is more efficient than conventional algorithms to find the list of prime numbers.
  • The Sieve of Eratosthenes is one of the most efficient ways to find all primes smaller than 'n' when n < 10,000,000

Algorithm

  1. Store the numbers from 2 to n in an array.
  2. Let p equal to 2 the first prime number.
  3. Starting from p mark all the numbers which are multiples of p like 2p, 3p, 4p .... xp, such that xp <= n.
  4. Then in the next loop print all the unmarked numbers, as these are the numbers which are prime.

Contributing

  • To contribute you can read up the CONTRIBUTING.md document, to understand how to contribute to the repository.

  • The current repository is maintained by Aditya Anantharaman. There are currently 4 implementation that are done.

How to run code?

C

  • Compile the code using the GCC compiler. Then execute the binary file.
cd Sieve/
gcc Sieve.c -o sieve
./sieve

C++

  • Compile the code using the G++ compiler. Then execute the binary file.
cd Sieve/
g++ Sieve.cpp -o sieve
./sieve

Java

  • Compile the code using the Java interpreter. Then execute the binary file.
cd Sieve/
javac Sieve.java 
java Sieve

Python

  • Run the Python program using the Python Program.
cd Sieve/
python Sieve.py

sieve-of-eratosthenes's People

Contributors

aditya5558 avatar sbshah97 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.