Skip to content

Commit 57c0fda

Browse files
author
GUO Joanna
committed
Add files via upload
0 parents  commit 57c0fda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+7101
-0
lines changed

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021 JamesJ
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
[![Downloads](https://static.pepy.tech/personalized-badge/find-primes?period=total&units=international_system&left_color=lightgrey&right_color=yellowgreen&left_text=Downloads)](https://pepy.tech/project/find-primes)
2+
3+
Find Primes is a library to find all kinds of primes and factors of big numbers.
4+
5+
**Install**
6+
7+
Stable Version:
8+
```shell
9+
pip install -U find-primes
10+
```
11+
Beta Version:
12+
```shell
13+
pip install --pre -U find-primes
14+
```
15+
16+
**[Twin Primes](https://en.wikipedia.org/wiki/Twin_prime)**
17+
18+
A twin prime is a prime number that is either 2 less or 2 more than another prime number.
19+
20+
Example: Find all twin primes below 1000.
21+
```python
22+
from find_primes import find_twins
23+
print(find_twins(1000))
24+
```
25+
26+
**[Palindrome Primes](https://en.wikipedia.org/wiki/Palindromic_prime)**
27+
28+
A palindrome prime is a prime number that is also a palindrome number.
29+
30+
Example: Find all palindrome primes below 1000.
31+
```python
32+
from find_primes import find_palindromes
33+
print(find_palindromes(1000))
34+
```
35+
36+
Example: Find all palindrome primes below 1000 in base 2.
37+
```python
38+
from find_primes import find_palindromes_base_2
39+
print(find_palindromes(8200)) #return in base 10
40+
```
41+
42+
**[Emirps](https://en.wikipedia.org/wiki/Emirp)**
43+
44+
An emirp is a prime number that results in a different prime when its decimal digits are reversed.
45+
46+
Example: Find all emirps below 1000.
47+
```python
48+
from find_primes import find_reverses
49+
print(find_reverses(1000))
50+
```
51+
52+
**[Primes in Arithmetic Progression](https://en.wikipedia.org/wiki/Primes_in_arithmetic_progression)**
53+
54+
Primes in arithmetic progression are any sequence of at least three prime numbers that are consecutive terms in an arithmetic progression.
55+
56+
Example: Find all primes in arithmetic progression below 1000.
57+
```python
58+
from find_primes import find_arithmetic_prime_progressions
59+
print(find_arithmetic_prime_progressions(100))
60+
```
61+
62+
**[Mersenne Primes](https://en.wikipedia.org/wiki/Mersenne_prime)**
63+
64+
A mersenne prime is a prime number that is one less than a power of two.
65+
66+
Example: Find all mersenne primes below 600000.
67+
```python
68+
from find_primes import find_mersenne
69+
print(find_mersenne(600000))
70+
```
71+
72+
**[Double Mersenne Primes](https://en.wikipedia.org/wiki/Double_Mersenne_number#Double_Mersenne_primes)**
73+
74+
A double mersenne prime is a double mersenne number that is prime.
75+
76+
Example: Find all double mersenne primes below 130.
77+
```python
78+
from find_primes import find_double_mersennes
79+
print(find_double_mersennes(130))
80+
```
81+
82+
**[Fermat Pseudoprimes](https://en.wikipedia.org/wiki/Fermat_pseudoprime)**
83+
84+
A fermat pseudoprime is a pseudoprime that satisfies fermat's little theorem.
85+
86+
Example: Find all fermat pseudoprimes below 1000.
87+
```python
88+
from find_primes import find_fermat_pseudoprimes
89+
print(find_fermat_pseudoprimes(1000))
90+
```
91+
92+
**[Balence Primes](https://en.wikipedia.org/wiki/Balanced_prime)**
93+
94+
A balence prime is a prime number which is equal to the arithmetic mean of the nearest primes above and below.
95+
96+
Example: Find all balence primes below 1000.
97+
```python
98+
from find_primes import find_balences
99+
print(find_balences(1000))
100+
```
101+
102+
**[Carol Primes](https://en.wikipedia.org/wiki/Carol_number#Primes_and_modular_relations)**
103+
104+
A carol prime is a carol number that is prime.
105+
106+
Example: Find all carol primes below 4000.
107+
```python
108+
from find_primes import find_carols
109+
print(find_carols(4000))
110+
```
111+
112+
**[Fibonacci Primes](https://en.wikipedia.org/wiki/Fibonacci_prime)**
113+
114+
A fibonacci prime is a fibonacci number that is prime.
115+
116+
Example: Find all fibonacci primes below 1000.
117+
```python
118+
from find_primes import find_fibonaccis
119+
print(find_fibonaccis(1000))
120+
```
121+
122+
**[Truncatable Primes](https://en.wikipedia.org/wiki/Truncatable_prime)**
123+
124+
A left-truncatable prime is a prime number which remains prime when the leading digit is successively removed.
125+
126+
Example: Find all left-truncatable primes below 140.
127+
```python
128+
from find_primes import find_truncates
129+
print(find_truncates(140, LEFT))
130+
```
131+
132+
A right-truncatable prime is a prime number which remains prime when the last digit is successively removed.
133+
134+
Example: Find all right-truncatable primes below 295.
135+
```python
136+
from find_primes import find_truncates
137+
print(find_truncates(295, RIGHT))
138+
```
139+
140+
A left-and-right-truncatable prime is a prime number which remains prime when the leading and last digits are simultaneously successively removed.
141+
142+
Example: Find all left-and-right-truncatable primes below 3800.
143+
```python
144+
from find_primes import find_truncates
145+
print(find_truncates(3800, BOTH))
146+
```
147+
148+
**[Cuban Primes](https://en.wikipedia.org/wiki/Cuban_prime)**
149+
150+
A cuban prime is a prime number that is a solution to a specific equation involving third powers of x and y.
151+
152+
Example: Find all cuban primes below 440.
153+
```python
154+
from find_primes import find_cubans
155+
print(find_cubans(440))
156+
```
157+
158+
**[Center Polygonal Primes](https://en.wikipedia.org/wiki/Centered_polygonal_number)**
159+
160+
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.
161+
162+
Example: Find all centered triangular primes below 1000.
163+
```python
164+
from find_primes import find_center_polygons
165+
print(find_center_polygons(1000, TRIANGLE))
166+
```
167+
168+
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.
169+
170+
Example: Find all centered square primes below 1000.
171+
```python
172+
from find_primes import find_center_polygons
173+
print(find_center_polygons(1000, SQUARE))
174+
```
175+
176+
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.
177+
178+
Example: Find all centered pentagonal primes below 1000.
179+
```python
180+
from find_primes import find_center_polygons
181+
print(find_center_polygons(1000, PENTAGON))
182+
```
183+
184+
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.
185+
186+
Example: Find all centered hexagonal primes below 1000.
187+
```python
188+
from find_primes import find_center_polygons
189+
print(find_center_polygons(1000, HEXAGON))
190+
```
191+
192+
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.
193+
194+
Example: Find all centered heptagon primes below 1000.
195+
```python
196+
from find_primes import find_center_polygons
197+
print(find_center_polygons(1000, HEPTAGON))
198+
```
199+
200+
**[Wieferich Primes](https://en.wikipedia.org/wiki/Wieferich_prime)**
201+
202+
A wieferich prime is a prime p that <img src="https://latex.vimsky.com/test.image.latex.php?fmt=png&val=%255Cdpi%257B150%257D%2520%255Clarge%2520p%2520%255E%257B2%257D&dl=0" width = "13.5" height = "15"> divides <img src="https://latex.vimsky.com/test.image.latex.php?fmt=png&val=%255Cdpi%257B150%257D%2520%255Clarge%25202%255E%257Bp-1%257D-1&dl=0" height = "15">.
203+
204+
Example: Find all wieferich primes below 4000.
205+
```python
206+
from find_primes import find_wieferiches
207+
print(find_wieferiches(3515))
208+
```
209+
210+
**[Wilson Primes](https://en.wikipedia.org/wiki/Wilson_prime)**
211+
212+
A wilson prime is a prime p that <img src="https://latex.vimsky.com/test.image.latex.php?fmt=png&val=%255Cdpi%257B150%257D%2520%255Clarge%2520p%2520%255E%257B2%257D&dl=0" width = "13.5" height = "15"> divides <img src="https://latex.vimsky.com/test.image.latex.php?fmt=png&val=%255Cdpi%257B150%257D%2520%255Clarge%2520%2528p-1%2529%2521%26plus%3B1&dl=0" width = "80" height = "15">.
213+
214+
Example: Find all wilson primes below 565.
215+
```python
216+
from find_primes import find_wilsons
217+
print(find_wilsons(565))
218+
```
219+
220+
**[Happy Primes](https://en.wikipedia.org/wiki/Happy_number#Happy_primes)**
221+
222+
A happy prime is a prime that is a happy number.
223+
224+
Example: Find all happy primes in base 10 below 195.
225+
```python
226+
from find_primes import find_happys
227+
print(find_happys(195))
228+
```
229+
230+
**[Pierpont Primes](https://en.wikipedia.org/wiki/Pierpont_prime)**
231+
232+
A Pierpont prime is a prime of the form <img src="https://latex.vimsky.com/test.image.latex.php?fmt=png&val=%255Cdpi%257B150%257D%2520%255Clarge%25202%257B%255Eu%257D%255Ccdot3%257B%255Ev%257D%26plus%3B1&dl=0" width = "80" height = "15">.
233+
234+
Example: Find all pierpont primes below 770.
235+
```python
236+
from find_primes import find_pierponts
237+
print(find_pierponts(770))
238+
```
239+
240+
**[Leyland Primes](https://en.wikipedia.org/wiki/Leyland_number#Leyland_primes)**
241+
242+
A leyland prime is a leyland number that is a prime.
243+
244+
Example: Find all leyland primes below 33000.
245+
```python
246+
from find_primes import find_leylands
247+
print(find_leylands(33000))
248+
```
249+
250+
**[Leyland Primes of a Second Kind](https://en.wikipedia.org/wiki/Leyland_number#Leyland_number_of_the_second_kind)**
251+
252+
A leyland prime of a second kind is a leyland number of a second kind that is a prime.
253+
254+
Example: Find all leyland primes of a second kind below 58050.
255+
```python
256+
from find_primes import find_leylands_second_kind
257+
print(find_leylands_second_kind(58050))
258+
```
259+
260+
**[MPQS Method](https://www.rieselprime.de/ziki/Multiple_polynomial_quadratic_sieve)**
261+
262+
The Multiple Polynomial Quadratic Sieve (MPQS) method is a factorization method.
263+
264+
Example: Factor a big number.
265+
```python
266+
from find_primes import factor_mpqs
267+
print(factor_mpqs(2776889953055853600532696901))
268+
```
269+
270+
**[SIQS Method](https://www.rieselprime.de/ziki/Self-initializing_quadratic_sieve)**
271+
272+
The Self-initializing Quadratic Sieve (SIQS) method is a factorization method based on the Multiple Polynomial Quadratic Sieve (MPQS) method.
273+
274+
Example: Factor a big number.
275+
```python
276+
from find_primes import factor_siqs
277+
print(factor_siqs(3458280484189))
278+
```
279+
280+
**[Lenstra Elliptic-curve Method](https://en.wikipedia.org/wiki/Lenstra_elliptic-curve_factorization)**
281+
282+
The Lenstra Elliptic-curve method is a factorization method.
283+
284+
Example: Factor a big number.
285+
```python
286+
from find_primes import factor_lenstra
287+
print(factor_lenstra(2854159729781))
288+
```
289+
290+
**[Pollard p - 1 Method](https://en.wikipedia.org/wiki/Pollard%27s_p_%E2%88%92_1_algorithm)**
291+
292+
The Pollard p - 1 method is a factorization method.
293+
294+
Example: Factor a big number.
295+
```python
296+
from find_primes import factor_pollardpm1
297+
print(factor_pollardpm1(2854159729781))
298+
```
299+
300+
**[Williams p + 1 Method](https://en.wikipedia.org/wiki/Williams%27s_p_%2B_1_algorithm)**
301+
302+
The Williams p + 1 Method is a factorization method.
303+
304+
Example: Factor a big number.
305+
```python
306+
from find_primes import factor_williamspp1
307+
print(factor_williamspp1(2854159729781))
308+
```

0 commit comments

Comments
 (0)