Skip to content

A Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form M_{n}=2^{n}-1 for some integer n.

License

Notifications You must be signed in to change notification settings

StokicDusan/MersennePrime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Commit-activity Issues Repo-size License
Forks LinkedIn

Welcome to MersennePrime

A Mersenne prime is a prime number that is one less than a power of two. It is a prime number of the form $M_{n} = 2^{n}-1$ for some integer $n$.

What does the script do?

The script prints Mersenne prime numbers on the command line.

mersennePrimes.py :

This script is ready to use script which uses one arguments to run. The argument is the integer passed for the number of primes to be printed.

mersenne_primes:

Function prints numbers divided by a space character.
Invoking the script runs this function.

mersenne_primes_format:

Function prints every number in a new line formatted to display in the $2^{n}-1$ form as well.

Installing the dependencies

Used packages

This script require the math, doctest and sys package.

How to use it

1. Clone this repository:

$ git clone https://github.com/StokicDusan/MersennePrime
$ cd MersennePrime/

2. Launch:

In the command line simply invoke the script with one argument:

$ python mersennePrimes.py argv1
  • argv1:
    Any positive integer

⚠️ Note: Other input will result in an error

Invoking the script with no arguments will run testmod().

Examples

The following code block shows examples of calling the mersennePrimes script from terminal.

$ python3 mersennePrimes.py -20

$ python3 mersennePrimes.py 0

$ python3 mersennePrimes.py 1
3

$ python3 mersennePrimes.py 9
3 7 31 127 8191 131071 524287 2147483647 2305843009213693951

Provide Feedback 👍

If you encounter any bugs or have suggestions, please file an issue in the Issues section of the project.

About

A Mersenne prime is a prime number that is one less than a power of two. That is, it is a prime number of the form M_{n}=2^{n}-1 for some integer n.

Topics

Resources

License

Stars

Watchers

Forks

Languages