Predicting Prime Numbers Using Cartesian Genetic Programming

  • James Alfred Walker
  • Julian Francis Miller
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4445)


Prime generating polynomial functions are known that can produce sequences of prime numbers (e.g. Euler polynomials). However, polynomials which produce consecutive prime numbers are much more difficult to obtain. In this paper, we propose approaches for both these problems. The first uses Cartesian Genetic Programming (CGP) to directly evolve integer based prime-prediction mathematical formulae. The second uses multi-chromosome CGP to evolve a digital circuit, which represents a polynomial. We evolved polynomials that can generate 43 primes in a row. We also found functions capable of producing the first 40 consecutive prime numbers, and a number of digital circuits capable of predicting up to 208 consecutive prime numbers, given consecutive input values. Many of the formulae have been previously unknown.


Prime Number Active Node Digital Circuit Program Input Program Output 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Wells, D.: Prime Numbers. John Wiley and sons, New York (2005)Google Scholar
  2. 2.
    Euler, L.: Extrait d’un lettre de m. euler le pere a m. bernoulli concernant le memoire imprime parmi ceux de 1771. Nouveaux Mémoires de l’Académie royale des Sciences de Berlin, Histoire, pp. 35–36 (1772)Google Scholar
  3. 3.
    Legendre, A.M.: Théorie des nombres, 2 edn. Libraire Scientifique A. Herman (1808)Google Scholar
  4. 4.
    Mollin, R.: Quadratics. Boca Raton (1995)Google Scholar
  5. 5.
    Mollin, R.: Prime-producing quadratics. American Mathematical Monthly 104(6), 529–544 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Pegg Jr., E.: Math games: Prime generating polynomialsGoogle Scholar
  7. 7.
    Fung, G., Williams, H.: Quadratic polynomials which have a high density of prime values. Mathematics of Computation 55, 345–353 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Mollin, R.: New prime-producing quadratic polynomials associated with class number one or two. New. York Journal of Mathematics 8, 161–168 (2002)zbMATHMathSciNetGoogle Scholar
  9. 9.
    Harrell, H.: Prime Producing Equations: The Distribution of Primes and Composites Within a Special Number Arrangement. AuthorHouse, Bloomington (2002)Google Scholar
  10. 10.
    Miller, J.F., Thomson, P.: Cartesian genetic programming. In: Poli, R., Banzhaf, W., Langdon, W.B., Miller, J., Nordin, P., Fogarty, T.C. (eds.) EuroGP 2000. LNCS, vol. 1802, pp. 121–132. Springer, Heidelberg (2000)Google Scholar
  11. 11.
    Walker, J.A., Miller, J.F.: A multi-chromosome approach to standard and embedded cartesian genetic programming. In: Proceedings of the 26 Genetic and Evolutionary Computation Conference (GECCO 26), vol. 1, Seattle, Washington, USA, 8-12 July, pp. 903–910. ACM Press, New York (2006)Google Scholar
  12. 12.
    Koza, J.R.: Genetic Programming: On the Programming of Computers by Means of Natural Selection. MIT Press, Cambridge (1992)zbMATHGoogle Scholar
  13. 13.
    Poli, R.: Parallel Distributed Genetic Programming. Technical Report CSRP-96-15, School of Computer Science, University of Birmingham, B15 2TT, UK (September 1996)Google Scholar
  14. 14.
    Yu, T., Miller, J.F.: Neutrality and the evolvability of boolean function landscape. In: Miller, J., Tomassini, M., Lanzi, P.L., Ryan, C., Tetamanzi, A.G.B., Langdon, W.B. (eds.) EuroGP 2001. LNCS, vol. 2038, pp. 204–217. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  15. 15.
    Vassilev, V.K., Miller, J.F.: The advantages of landscape neutrality in digital circuit evolution. In: Miller, J.F., Thompson, A., Thompson, P., Fogarty, T.C. (eds.) ICES 2000. LNCS, vol. 1801, pp. 252–263. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  16. 16.
    Walker, J.A., Miller, J.F.: The automatic acquisition, evolution and re-use of modules in cartesian genetic programming. Accepted for publication in IEEE Transactions on Evolutionary ComputationGoogle Scholar

Copyright information

© Springer Berlin Heidelberg 2007

Authors and Affiliations

  • James Alfred Walker
    • 1
  • Julian Francis Miller
    • 1
  1. 1.Intelligent Systems Group, Department of Electronics, University of York, Heslington, York, YO10 5DDUK

Personalised recommendations