Submitted:
02 March 2025
Posted:
03 March 2025
You are already at the latest version
Abstract
Prime numbers and methods of their generation have attracted mathematicians for centuries and, in the digital age, have found their applications in cryptography, signal processing and data compression, secure communications, hashing algorithms, cybersecurity, quantum computing algorithms, blockchain technology, and other areas. Prime numbers and prime generating polynomials were studied in [1-20]. There are many prime generating polynomials of different degrees \cite{weisstein2005} found so far; the most famous of them is \(x^2+x+41\) found by Euler in 1772 and \(x^2-x+41\) found by Legendre in 1798. Researchers are curious to find such a polynomial \(P(x) = a_n x^n + a_{n-1} x^{n-1} + \dots + a_1 x + a_0\) that produces more prime numbers for given integer values of \(x\). This work is no exception, but the reader will not find any mathematical formulas or theorems as in mathematical works; instead, we want to show the result of our computational experiments in the programming language Julia, which in particular led to the discovery of quadratic polynomials that, similarly to Euler's prime generating polynomial, generate 40 primes. We also show that some of the currently known polynomials are not the richest in terms of the percentage of primes appearing in larger intervals, i.e. they produce fewer primes. For a better and more systematic understanding of what happens in prime number research, we demonstrate a video with network visualisation of keyword co-occurrence and co-authorship based on data from 7548 documents indexed in the Scopus database. Readers of this work are welcome to send me comments, suggestions, or proposals for collaborative research on prime numbers and their applications in science and engineering.
Keywords:
prime numbers
; quadratic polynomial
; Julia programming language
MSC: Primary 11N05; Secondary 11N13; 11Y11
1. Where Are Prime Numbers Used?
Prime numbers and methods of generating them have fascinated mathematicians for centuries and, in the digital age, have found applications in cryptography, signal processing and data compression, secure communications, hashing algorithms, cybersecurity, quantum computing algorithms, blockchain technology, machinery and other areas. For example, in gear design, multiple gears often have a relatively prime number of teeth to ensure even wear of the teeth. For example, if two gears have 16 and 8 teeth, the same teeth of the first gear will always meet the same teeth of the second gear, and the wear of a single tooth can cause the wear of the tooth of the other gear.
2. Networks of Keywords and Co-Authors of Scopus Documents on Prime Numbers
The query TITLE-ABS-KEY ("prime number") was used in Scopus to find the related documents. Using the software VOSviewer1, we analysed the keywords of 7548 documents, and the visualisation of the keyword and co-authorship network is available at
Our analysis showed that the most popular keywords are cryptography, number theory, algorithms, public key cryptography, polynomials, finite fields, codes, data security, factorisation, matrix algebra, network security, RSA2, computational complexity, geometry, algebra, graph theory, computational theory, encryption, RSA algorithms, theorem proving, authentication, elliptic curve, and others.
3. Julia Code for Checking Prime Numbers
The computational experiments were carried out in the Julia3 v. 1.11.2 programming language on a computer with an Intel® CoreTM i5-10500 CPU at 3.10 GHz, 8.00 GB of RAM, 64-bit architecture, and Windows 11 operating system.
- using Primes # Import the Primes package
- function compute_prime_stats()
- # Define the polynomial function
- f(x) = x^2 - x + 41
- total_count = 10^7
- prime_count = 0
- max_streak = 0
- current_streak = 0
- # Loop through values of x from 0 to total_count
- for x in 0:total_count
- value = f(x)
- if isprime(value)
- prime_count += 1
- current_streak += 1
- else
- max_streak = max(max_streak, current_streak)
- current_streak = 0
- end
- println("f($x) = $value -> Prime: ", isprime(value))
- end
- # Check in case the last numbers were primes
- max_streak = max(max_streak, current_streak)
- prime_percentage = (prime_count / total_count) * 100
- println("Percentage of prime numbers: $prime_percentage%")
- println("Maximum number of prime values: $max_streak")
- end
- # Execute the function
- @time compute_prime_stats()
For prime generating polynomial for , in 27.230569 seconds (23 allocations: 1008 bytes), the program determined that 22.08% of the values were prime and recorded a maximum streak of 40 prime numbers.
4. Results of the Computational Experiment
In the following tables, are the coefficients of a quadratic polynomial, and the other columns show how many primes are found in a given range.
Table 1.
Prime-generating polynomials with positive that produce 30 prime numbers (some of them can produce even more).
Table 1.
Prime-generating polynomials with positive that produce 30 prime numbers (some of them can produce even more).
| No. | a | b | c | Number of primes | Percentage |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 41 | 30 | 100.0 |
| 2 | 1 | 3 | 43 | 30 | 100.0 |
| 3 | 1 | 5 | 47 | 30 | 100.0 |
| 4 | 1 | 7 | 53 | 30 | 100.0 |
| 5 | 1 | 9 | 61 | 30 | 100.0 |
| 6 | 1 | 11 | 71 | 30 | 100.0 |
| 7 | 1 | 13 | 83 | 30 | 100.0 |
| 8 | 1 | 15 | 97 | 30 | 100.0 |
| 9 | 1 | 17 | 113 | 30 | 100.0 |
| 10 | 1 | 19 | 131 | 30 | 100.0 |
| 11 | 1 | 21 | 151 | 30 | 100.0 |
Table 2.
Prime-generating polynomials that produce 40 prime numbers (note that some polynomials are likely to produce more primes and can be independently checked using the Julia code). Euler’s prime-generating polynomial and some others can also be found among the results.
Table 2.
Prime-generating polynomials that produce 40 prime numbers (note that some polynomials are likely to produce more primes and can be independently checked using the Julia code). Euler’s prime-generating polynomial and some others can also be found among the results.
| No. | a | b | c | Number of primes | Percentage |
|---|---|---|---|---|---|
| 1 | 1 | -61 | 971 | 40 | 100.0 |
| 2 | 1 | -59 | 911 | 40 | 100.0 |
| 3 | 1 | -57 | 853 | 40 | 100.0 |
| 4 | 1 | -55 | 797 | 40 | 100.0 |
| 5 | 1 | -53 | 743 | 40 | 100.0 |
| 6 | 1 | -51 | 691 | 40 | 100.0 |
| 7 | 1 | -49 | 641 | 40 | 100.0 |
| 8 | 1 | -47 | 593 | 40 | 100.0 |
| 9 | 1 | -45 | 547 | 40 | 100.0 |
| 10 | 1 | -43 | 503 | 40 | 100.0 |
| 11 | 1 | -41 | 461 | 40 | 100.0 |
| 12 | 1 | -39 | 421 | 40 | 100.0 |
| 13 | 1 | -37 | 383 | 40 | 100.0 |
| 14 | 1 | -35 | 347 | 40 | 100.0 |
| 15 | 1 | -33 | 313 | 40 | 100.0 |
| 16 | 1 | -31 | 281 | 40 | 100.0 |
| 17 | 1 | -29 | 251 | 40 | 100.0 |
| 18 | 1 | -27 | 223 | 40 | 100.0 |
| 19 | 1 | -25 | 197 | 40 | 100.0 |
| 20 | 1 | -23 | 173 | 40 | 100.0 |
| 21 | 1 | -21 | 151 | 40 | 100.0 |
| 22 | 1 | -19 | 131 | 40 | 100.0 |
| 23 | 1 | -17 | 113 | 40 | 100.0 |
| 24 | 1 | -15 | 97 | 40 | 100.0 |
| 25 | 1 | -13 | 83 | 40 | 100.0 |
| 26 | 1 | -11 | 71 | 40 | 100.0 |
| 27 | 1 | -9 | 61 | 40 | 100.0 |
| 28 | 1 | -7 | 53 | 40 | 100.0 |
| 29 | 1 | -5 | 47 | 40 | 100.0 |
| 30 | 1 | -3 | 43 | 40 | 100.0 |
| 31 | 1 | -1 | 41 | 40 | 100.0 |
| 32 | 1 | 1 | 41 | 40 | 100.0 |
| 33 | 2 | -88 | 997 | 40 | 100.0 |
| 34 | 2 | -84 | 911 | 40 | 100.0 |
| 35 | 2 | -80 | 829 | 40 | 100.0 |
| 36 | 2 | -76 | 751 | 40 | 100.0 |
| 37 | 2 | -72 | 677 | 40 | 100.0 |
| 38 | 2 | -68 | 607 | 40 | 100.0 |
| 39 | 2 | -64 | 541 | 40 | 100.0 |
| 40 | 2 | -60 | 479 | 40 | 100.0 |
| 41 | 2 | -56 | 421 | 40 | 100.0 |
| 42 | 2 | -52 | 367 | 40 | 100.0 |
| 43 | 2 | -48 | 317 | 40 | 100.0 |
| 44 | 2 | -44 | 271 | 40 | 100.0 |
| 45 | 3 | -105 | 941 | 40 | 100.0 |
| 46 | 6 | -150 | 967 | 40 | 100.0 |
| 47 | 6 | -138 | 823 | 40 | 100.0 |
| 48 | 6 | -126 | 691 | 40 | 100.0 |
Table 3.
One hundred prime generating polynomials with positive and thirteen quadratic polynomials from [18] for values of x up to 10.000. Polynomials 9 and 10 from the bottom of the table can also be found in Table 3 (polynomials 56 and 21, respectively).
Table 3.
One hundred prime generating polynomials with positive and thirteen quadratic polynomials from [18] for values of x up to 10.000. Polynomials 9 and 10 from the bottom of the table can also be found in Table 3 (polynomials 56 and 21, respectively).
| No. | a | b | c | Number of primes | Percentage |
|---|---|---|---|---|---|
| 1 | 2 | 44 | 43 | 4366 | 43.6556 |
| 2 | 2 | 40 | 1 | 4365 | 43.6456 |
| 3 | 1 | 1 | 41 | 4149 | 41.4859 |
| 4 | 1 | 3 | 43 | 4149 | 41.4859 |
| 5 | 1 | 5 | 47 | 4148 | 41.4759 |
| 6 | 6 | 6 | 31 | 3859 | 38.5861 |
| 7 | 6 | 18 | 43 | 3858 | 38.5761 |
| 8 | 4 | 2 | 41 | 3836 | 38.3562 |
| 9 | 4 | 10 | 47 | 3835 | 38.3462 |
| 10 | 2 | 40 | 19 | 3805 | 38.0462 |
| 11 | 4 | 6 | 43 | 3785 | 37.8462 |
| 12 | 1 | 35 | 23 | 3663 | 36.6263 |
| 13 | 9 | 9 | 43 | 3637 | 36.3664 |
| 14 | 9 | 3 | 41 | 3604 | 36.0364 |
| 15 | 9 | 15 | 47 | 3602 | 36.0164 |
| 16 | 24 | 12 | 31 | 3598 | 35.9764 |
| 17 | 2 | 34 | 31 | 3580 | 35.7964 |
| 18 | 24 | 36 | 43 | 3577 | 35.7664 |
| 19 | 16 | 4 | 41 | 3534 | 35.3365 |
| 20 | 16 | 20 | 47 | 3524 | 35.2365 |
| 21 | 3 | 39 | 37 | 3510 | 35.0965 |
| 22 | 3 | 33 | 1 | 3509 | 35.0865 |
| 23 | 7 | 49 | 41 | 3509 | 35.0865 |
| 24 | 10 | 20 | 29 | 3491 | 34.9065 |
| 25 | 22 | 22 | 17 | 3484 | 34.8365 |
| 26 | 2 | 4 | 31 | 3483 | 34.8265 |
| 27 | 2 | 8 | 37 | 3483 | 34.8265 |
| 28 | 2 | 12 | 47 | 3482 | 34.8165 |
| 29 | 16 | 12 | 43 | 3468 | 34.6765 |
| 30 | 25 | 25 | 47 | 3467 | 34.6665 |
| 31 | 1 | 23 | 23 | 3446 | 34.4566 |
| 32 | 1 | 25 | 47 | 3446 | 34.4566 |
| 33 | 1 | 21 | 1 | 3445 | 34.4466 |
| 34 | 25 | 5 | 41 | 3412 | 34.1166 |
| 35 | 7 | 7 | 17 | 3409 | 34.0866 |
| 36 | 7 | 21 | 31 | 3409 | 34.0866 |
| 37 | 1 | 37 | 29 | 3405 | 34.0466 |
| 38 | 38 | 40 | 1 | 3404 | 34.0366 |
| 39 | 33 | 15 | 11 | 3392 | 33.9166 |
| 40 | 36 | 18 | 43 | 3388 | 33.8766 |
| 41 | 36 | 30 | 47 | 3388 | 33.8766 |
| 42 | 35 | 35 | 19 | 3387 | 33.8666 |
| 43 | 36 | 6 | 41 | 3381 | 33.8066 |
| 44 | 25 | 15 | 43 | 3375 | 33.7466 |
| 45 | 43 | 3 | 1 | 3374 | 33.7366 |
| 46 | 49 | 35 | 47 | 3360 | 33.5966 |
| 47 | 47 | 5 | 1 | 3356 | 33.5566 |
| 48 | 41 | 1 | 1 | 3355 | 33.5466 |
| 49 | 32 | 18 | 47 | 3344 | 33.4367 |
| 50 | 20 | 20 | 43 | 3342 | 33.4167 |
| 51 | 49 | 21 | 43 | 3339 | 33.3867 |
| 52 | 49 | 7 | 41 | 3314 | 33.1367 |
| 53 | 34 | 46 | 23 | 3306 | 33.0567 |
| 54 | 1 | 27 | 13 | 3305 | 33.0467 |
| 55 | 1 | 29 | 41 | 3305 | 33.0467 |
| 56 | 3 | 3 | 23 | 3299 | 32.9867 |
| 57 | 3 | 9 | 29 | 3298 | 32.9767 |
| 58 | 3 | 15 | 41 | 3298 | 32.9767 |
| 59 | 34 | 22 | 11 | 3287 | 32.8667 |
| 60 | 40 | 40 | 29 | 3267 | 32.6667 |
| 61 | 8 | 8 | 31 | 3263 | 32.6267 |
| 62 | 8 | 24 | 47 | 3263 | 32.6267 |
| 63 | 8 | 16 | 37 | 3243 | 32.4268 |
| 64 | 4 | 46 | 23 | 3242 | 32.4168 |
| 65 | 23 | 35 | 1 | 3222 | 32.2168 |
| 66 | 14 | 6 | 29 | 3214 | 32.1368 |
| 67 | 14 | 34 | 49 | 3214 | 32.1368 |
| 68 | 2 | 30 | 29 | 3211 | 32.1068 |
| 69 | 2 | 26 | 1 | 3210 | 32.0968 |
| 70 | 26 | 32 | 43 | 3206 | 32.0568 |
| 71 | 46 | 46 | 17 | 3203 | 32.0268 |
| 72 | 28 | 42 | 31 | 3185 | 31.8468 |
| 73 | 33 | 33 | 41 | 3172 | 31.7168 |
| 74 | 28 | 14 | 17 | 3154 | 31.5368 |
| 75 | 14 | 22 | 37 | 3146 | 31.4569 |
| 76 | 18 | 12 | 31 | 3142 | 31.4169 |
| 77 | 18 | 36 | 47 | 3133 | 31.3269 |
| 78 | 42 | 30 | 29 | 3131 | 31.3069 |
| 79 | 22 | 14 | 11 | 3123 | 31.2269 |
| 80 | 15 | 45 | 1 | 3117 | 31.1669 |
| 81 | 26 | 20 | 37 | 3109 | 31.0869 |
| 82 | 4 | 42 | 1 | 3107 | 31.0669 |
| 83 | 4 | 50 | 47 | 3107 | 31.0669 |
| 84 | 15 | 15 | 17 | 3102 | 31.0169 |
| 85 | 15 | 45 | 47 | 3101 | 31.0069 |
| 86 | 7 | 49 | 23 | 3096 | 30.9569 |
| 87 | 18 | 24 | 37 | 3089 | 30.8869 |
| 88 | 13 | 27 | 1 | 3086 | 30.8569 |
| 89 | 46 | 20 | 47 | 3082 | 30.8169 |
| 90 | 11 | 9 | 11 | 3080 | 30.7969 |
| 91 | 11 | 31 | 31 | 3079 | 30.7869 |
| 92 | 11 | 13 | 13 | 3075 | 30.7469 |
| 93 | 11 | 35 | 37 | 3074 | 30.7369 |
| 94 | 25 | 17 | 17 | 3073 | 30.7269 |
| 95 | 33 | 15 | 19 | 3068 | 30.6769 |
| 96 | 32 | 32 | 37 | 3065 | 30.6469 |
| 97 | 1 | 19 | 17 | 3061 | 30.6069 |
| 98 | 22 | 30 | 19 | 3061 | 30.6069 |
| 99 | 1 | 21 | 37 | 3060 | 30.5969 |
| 100 | 26 | 26 | 37 | 3060 | 30.5969 |
| 1 | 36 | -810 | 2753 | 3981 | 39.81 |
| 2 | 47 | -1701 | 10181 | 3758 | 37.58 |
| 3 | 103 | -4707 | 50383 | 3874 | 38.74 |
| 4 | 43 | -537 | 2971 | 3808 | 38.08 |
| 5 | 8 | -488 | 7243 | 4048 | 40.48 |
| 6 | 6 | -342 | 4903 | 3874 | 38.74 |
| 7 | 2 | 0 | 29 | 3484 | 34.84 |
| 8 | 7 | -371 | 4871 | 3526 | 35.26 |
| 9 | 3 | 3 | 23 | 3299 | 32.99 |
| 10 | 3 | 39 | 37 | 3510 | 35.10 |
| 11 | 1 | 1 | 17 | 2628 | 26.28 |
| 12 | 4 | 4 | 59 | 3408 | 34.08 |
| 13 | 2 | 0 | 11 | 2080 | 20.8 |
5. Conclusion
Using the Julia programming language, we have carried out a computational experiment and found quadratic polynomials rich in primes in a given range. Some of these polynomials may have already been found by others, so the reader can check them more carefully using the provided Julia code. The results can be updated and extended by increasing the range of x and , which will, of course, increase the computational cost.
References
- Coman, M. (n.d.). A list of known root prime-generating quadratic polynomials producing more than 23 distinct primes in a row.
- DeBenedetto, J., & Rouse, J. (2012). A 60,000 digit prime number of the form x2+x+41. arXiv. arXiv:1207.7291.
- Diouf, M.(2017). Prime-Generating Polynomial arXiv. arXiv:1702.06276.
- Fuentes, F., Meirose, M., & Tou, E. R. (2017). Quadratic prime-generating polynomials over the Gaussian integers. Pi Mu Epsilon Journal, 14(6), 365-372.
- Heffernan, R., Lord, N., & MacHale, D. (2024). Euler’s prime-producing polynomial revisited. The Mathematical Gazette, 108(571), 69-77. [CrossRef]
- Hunter, J. A. H. (1965). n2+21n+1 as a generator of primes. Mathematics Magazine, 38(4), 232-232.
- Kravitz, S. (1962). Elementary observations concerning Euler’s prime-generating polynomial f(n)=n2-n+41. Mathematics Magazine, 35(3), 152-152.
- Lee, J. H. (2023). Prime-producing polynomials related to class number one problem of number fields. Bulletin of the Korean Mathematical Society, 60(2), 315-323.
- Mollin, R. (1996). Quadratic polynomials producing consecutive, distinct primes and class groups of complex quadratic fields. Acta Arithmetica, 74(1), 17-30.
- Mollin, R. A. (1997). Prime-producing quadratics. The American Mathematical Monthly, 104(6), 529-544.
- Morizono, A. (2017). An analogy of Euler primes for a polynomial ring over a field (Doctoral dissertation, Kyushu University, Japan).
- Ribenboim, P. (2000). Euler’s famous prime-generating polynomial and the class number of imaginary quadratic fields. My Numbers, My Friends: Popular Lectures on Number Theory, 91-111.
- Shaghaghi, M. (n.d.). Exploring the Infinitude of Prime-Generating Functions: Extending the Mersenne Framework.
- Shchelkov, N. (n.d.). Systems of equations based on Euler’s polynomial that generate sequences of hundreds of prime numbers. Available at SSRN 4873470.
- Singh, S. (2024). Prime Generation via Polynomials: Analysis and Applications.
- Walker, J. A., & Miller, J. F. (2007). Predicting prime numbers using Cartesian genetic programming. In Genetic Programming: 10th European Conference, EuroGP 2007, Valencia, Spain, April 11-13, 2007. Proceedings 10 (pp. 205-216). Springer Berlin Heidelberg.
- Weisstein, E. W. (2000). Euler Number. Retrieved from https://mathworld.wolfram.com/.
- Weisstein, E. W. (2005). Prime-generating polynomial. Retrieved from https://mathworld.wolfram.com/.
- Xiaochun, M. (2021). The Problems Existing in the Complex Continuations of the Gamma Function and the Euler Formula of Prime Numbers.
- Savitsky, Z. (2024). ‘Sensational breakthrough’ marks step toward revealing hidden structure of prime numbers. Science. [CrossRef]
| 1 | |
| 2 | RSA (Rivest-Shamir-Adleman) is a public key cryptosystem, one of the oldest and most widely used for secure data transmission. |
| 3 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.