Giter Site home page Giter Site logo

mersenneprimenumbers's Introduction

Mersenne Prime Numbers

Mersenne primes are a subset of prime numbers that follow a particular pattern, where they can be expressed as "2^p - 1" form (with 'p' as prime number). Why this form? When 'p' is a prime number, "2^p" is an even number because it's a power of 2. Subtracting 1 from an even number results in an odd number.

The code besides the trial division method used to check if a number is prime, the code also utilizes the Lucas–Lehmer test (LLT) to determine if a given number is a prime exponent. How it works?

$$ s_i = \begin{cases} 4 & \text{if } i = 0 \\ s_{i-1}^2 - 2 & \text{otherwise}. \end{cases} $$

So if

$$ s_{p-2} \equiv 0 \ (\text{mod} \ M_p) $$

then the original prime number pp is a prime exponent, suggesting that M_p could be a Mersenne prime.

In order to show how this works, we've made a simple C program that check if a given number is prime and if it's a prime exponent, which is a necessary condition for a Mersenne prime about first 1M numbers.

Languages and Tools

C

Requirements

To build and run this project, you'll need:

  • CMake

Building the Project

Follow these steps to build the project using CMake:

  1. Clone the repository to your local machine: git clone https://github.com/FrancescoPaoloL/MersennePrimeNumbers.git
  2. Navigate to the project directory: cd your-repository
  3. Create a build directory: mkdir build --> cd build
  4. Generate the build files using CMake: cmake ..
  5. Build the project using the appropriate build tool (e.g., make): make

After following these steps, you should find the compiled executable in the build directory. You can run the executable to execute the program.

License

This project is licensed under the MIT License - see the LICENSE.md file for details


Connect with me

francescopaololezza francescopaololezza

mersenneprimenumbers's People

Contributors

francescopaolol avatar

Stargazers

 avatar

Watchers

 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.