Coder Social home page Coder Social logo

prime_gap_finder's Introduction

prime_gap_finder

This is a simple C++ program that finds the largest number of consecutive non-prime numbers (in other words, the maximum prime gap) below a certain limit. It uses a rather simple algorithm (segmented sieve) to find all the primes within the limit and the gaps between them. Thanks to the sieve segments/deltas/chunks being computable in parallel, I have parallelised the algorithm, and by default a thread per logical core will be used.

For perfomance reasons primes are assumed to fit in a 32-bit unsigned integer and thefore the limit is up to 2^32 - 1 by default. It can be changed simply by redefining Int in sieve.h.

Building

Simply use make to build the release version. No particular library is used, you only need a C++11 compiler. By default clang is used if available as it apparently produces better code, you can choose another compiler with CXX (e.g. make CXX=g++).

Running

To find the largest gap up to 2 billions: ./prime_gap_finder $((2*10**9))

prime_gap_finder's People

Contributors

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