Skip to main content

A module to find primes and factors of big numbers.

Project description

Downloads

Find Primes is a library to find all kinds of primes and factors of big numbers.

Install

Stable Version:

pip install -U find-primes

Beta Version:

pip install --pre -U find-primes

Find all primes below a number

Example: Find all primes below 100.

from find_primes import all_primes
print(all_primes(100, 'list'))

Check if a number is a prime

Example: Check if 189765 is a prime.

from find_primes import is_prime
print(is_prime(189765))

Factor a big number

Example: Factor 2776889953055853600532696901.

from find_primes import factor_mpqs
print(factor_mpqs(2776889953055853600532696901))

The CLI Tool

Usage:

find_primes.py --help

Twin Primes

A twin prime is a prime number that is either 2 less or 2 more than another prime number.

Example: Find all twin primes below 1000.

from find_primes import find_twins
print(find_twins(1000))

Palindrome Primes

A palindrome prime is a prime number that is also a palindrome number.

Example: Find all palindrome primes below 1000.

from find_primes import find_palindromes
print(find_palindromes(1000))

Example: Find all palindrome primes below 1000 in base 2.

from find_primes import find_palindromes_base_2
print(find_palindromes(8200)) #return in base 10

Emirps

An emirp is a prime number that results in a different prime when its decimal digits are reversed.

Example: Find all emirps below 1000.

from find_primes import find_reverses
print(find_reverses(1000))

Primes in Arithmetic Progression

Primes in arithmetic progression are any sequence of at least three prime numbers that are consecutive terms in an arithmetic progression.

Example: Find all primes in arithmetic progression below 1000.

from find_primes import find_arithmetic_prime_progressions
print(find_arithmetic_prime_progressions(100))

Mersenne Primes

A mersenne prime is a prime number that is one less than a power of two.

Example: Find all mersenne primes below 600000.

from find_primes import find_mersenne
print(find_mersenne(600000))

Double Mersenne Primes

A double mersenne prime is a double mersenne number that is prime.

Example: Find all double mersenne primes below 130.

from find_primes import find_double_mersennes
print(find_double_mersennes(130))

Fermat Pseudoprimes

A fermat pseudoprime is a pseudoprime that satisfies fermat's little theorem.

Example: Find all fermat pseudoprimes below 1000.

from find_primes import find_fermat_pseudoprimes
print(find_fermat_pseudoprimes(1000))

Balence Primes

A balence prime is a prime number which is equal to the arithmetic mean of the nearest primes above and below.

Example: Find all balence primes below 1000.

from find_primes import find_balences
print(find_balences(1000))

Carol Primes

A carol prime is a carol number that is prime.

Example: Find all carol primes below 4000.

from find_primes import find_carols
print(find_carols(4000))

Fibonacci Primes

A fibonacci prime is a fibonacci number that is prime.

Example: Find all fibonacci primes below 1000.

from find_primes import find_fibonaccis
print(find_fibonaccis(1000))

Truncatable Primes

A left-truncatable prime is a prime number which remains prime when the leading digit is successively removed.

Example: Find all left-truncatable primes below 140.

from find_primes import find_truncates
print(find_truncates(140, LEFT))

A right-truncatable prime is a prime number which remains prime when the last digit is successively removed.

Example: Find all right-truncatable primes below 295.

from find_primes import find_truncates
print(find_truncates(295, RIGHT))

A left-and-right-truncatable prime is a prime number which remains prime when the leading and last digits are simultaneously successively removed.

Example: Find all left-and-right-truncatable primes below 3800.

from find_primes import find_truncates
print(find_truncates(3800, BOTH))

Cuban Primes

A cuban prime is a prime number that is a solution to a specific equation involving third powers of x and y.

Example: Find all cuban primes below 440.

from find_primes import find_cubans
print(find_cubans(440))

Center Polygonal Primes

A centered triangular prime is a prime number and a centered figurate number that represents a triangle with a dot in the center and all other dots surrounding the center in successive triangular layers.

Example: Find all centered triangular primes below 1000.

from find_primes import find_center_polygons
print(find_center_polygons(1000, TRIANGLE))

A centered square prime is a prime number and a centered figurate number that represents a square with a dot in the center and all other dots surrounding the center in successive square layers.

Example: Find all centered square primes below 1000.

from find_primes import find_center_polygons
print(find_center_polygons(1000, SQUARE))

A centered pentagonal prime is a prime number and a centered figurate number that represents a pentagon with a dot in the center and all other dots surrounding the center in successive pentagonal layers.

Example: Find all centered pentagonal primes below 1000.

from find_primes import find_center_polygons
print(find_center_polygons(1000, PENTAGON))

A centered hexagonal prime is a prime number and a centered figurate number that represents a hexagon with a dot in the center and all other dots surrounding the center in successive hexagonal layers.

Example: Find all centered hexagonal primes below 1000.

from find_primes import find_center_polygons
print(find_center_polygons(1000, HEXAGON))

A centered heptagonal number is a prime number and a centered figurate number that represents a heptagon with a dot in the center and all other dots surrounding the center in successive heptagonal layers.

Example: Find all centered heptagon primes below 1000.

from find_primes import find_center_polygons
print(find_center_polygons(1000, HEPTAGON))

Wieferich Primes

A wieferich prime is a prime p that divides .

Example: Find all wieferich primes below 4000.

from find_primes import find_wieferiches
print(find_wieferiches(3515))

Wilson Primes

A wilson prime is a prime p that divides .

Example: Find all wilson primes below 565.

from find_primes import find_wilsons
print(find_wilsons(565))

Happy Primes

A happy prime is a prime that is a happy number.

Example: Find all happy primes in base 10 below 195.

from find_primes import find_happys
print(find_happys(195))

Pierpont Primes

A Pierpont prime is a prime of the form .

Example: Find all pierpont primes below 770.

from find_primes import find_pierponts
print(find_pierponts(770))

Leyland Primes

A leyland prime is a leyland number that is a prime.

Example: Find all leyland primes below 33000.

from find_primes import find_leylands
print(find_leylands(33000))

Leyland Primes of a Second Kind

A leyland prime of a second kind is a leyland number of a second kind that is a prime.

Example: Find all leyland primes of a second kind below 58050.

from find_primes import find_leylands_second_kind
print(find_leylands_second_kind(58050))

Woodall Primes

A woodall prime is a woodall number that is a prime.

Example: Find all woodall primes below 400.

from find_primes import find_woodalls
print(find_woodalls(400))

Unique Primes

A unique prime is a prime that there is no other prime q such that the period length of the decimal expansion of its reciprocal, 1 / p, is equal to the period length of the reciprocal of q, 1 / q.

Notice: You must install mpmath to find unique primes.

Example: Find all unique primes below 105.

from find_primes import find_uniques
print(find_uniques(105))

Friedman Primes

A friedman prime is a friedman number that is a prime.

Example: Find all friedman primes below 128.

from find_primes import find_friedmans
print(find_friedmans(128))

MPQS Method

The Multiple Polynomial Quadratic Sieve (MPQS) method is a factorization method.

Example: Factor a big number.

from find_primes import factor_mpqs
print(factor_mpqs(277688995305593400532696901))

SIQS Method

The Self-initializing Quadratic Sieve (SIQS) method is a factorization method based on the Multiple Polynomial Quadratic Sieve (MPQS) method.

Example: Factor a big number.

from find_primes import factor_siqs
print(factor_siqs(3458280484189))

Lenstra Elliptic-curve Method

The Lenstra Elliptic-curve method is a factorization method.

Example: Factor a big number.

from find_primes import factor_lenstra
print(factor_lenstra(2854159729781))

Pollard p - 1 Method

The Pollard p - 1 method is a factorization method.

Example: Factor a big number.

from find_primes import factor_pollardpm1
print(factor_pollardpm1(2854159729781))

Williams p + 1 Method

The Williams p + 1 Method is a factorization method.

Example: Factor a big number.

from find_primes import factor_williamspp1
print(factor_williamspp1(2854159729781))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

find_primes-2.2.1.tar.gz (42.2 kB view hashes)

Uploaded Source

Built Distribution

find_primes-2.2.1-py3-none-any.whl (41.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page