Advertisement

On the prime example of programming

  • Paul Pritchard
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 79)

Abstract

The problem of finding prime numbers has been much favoured by expositors of modern programming methodology. In this paper the problem is tackled once more, but from a broader view of the programming process than has previously been taken. The initial steps toward a solution parallel those in the well-known presentations of Dijkstra and Wirth. However a general program transformation is shown to capture the clever "inventive step" in Dijkstra's solution, and another is employed to lead naturally to an alternative program. Complexity analyses of the two programs show that the latter is significantly more efficient.

References

  1. BAYS, C., and HUDSON, R.H. (1977): "The Segmented Sieve of Eratosthenes and Primes in Arithmetic Progression to 1012". B.I.T., Vol. 17, pp 121–127.Google Scholar
  2. DIJKSTRA, E.W. (1972): "Notes on Structured Programming". In "Structured Programming", Academic Press, New York, pp. 1–82.Google Scholar
  3. DIJKSTRA, E.W. (1976): "A Discipline of Programming". Prentice-Hall, Englewood Cliffs, New Jersey.Google Scholar
  4. HARDY, G.H., and WRIGHT, E.M. (1965): "An Introduction to the Theory of Numbers". Fourth edition, O.U.P., London.Google Scholar
  5. HOARE, C.A.R. (1972): "Notes on Data Structuring". In "Structured Programming", Academic Press, New York, pp.83–174.Google Scholar
  6. MCMASTER, C.L. (1978): "An Analysis of Algorithms for the Dutch National Flag Problem". Comm. ACM, Vol. 21, No. 10, pp. 842–846.Google Scholar
  7. PRITCHARD, P.A. (1978): "Program Design Via Multiple-Pass Algorithms". Typescript, Canberra, dated May 1978.Google Scholar
  8. PRITCHARD, P.A. (1979a): "On the Prime Example of Programming". In "Variations on a Scheme of Eratosthenes", Tech. Report No. 8, Dept. of Computer Science, Univ. of Queensland, pp. 1–21.Google Scholar
  9. PRITCHARD, P.A. (1979b): "On a Proposed Method of Generating Prime Numbers". In "Variations on a Scheme of Eratosthenes", Tech. Report No. 8, Dept. of Computer Science, Univ. of Queensland, pp. 22–28.Google Scholar
  10. PRITCHARD, P.A. (1979c): "A Fast Linear Sieve for Finding Prime Numbers". In "Variations on a Scheme of Eratosthenes", Tech. Report. No. 8, Dept. of Computer Science, Univ. of Queensland, pp. 29–41.Google Scholar
  11. WIRTH, N. (1973): Systematic Programming: An Introduction. Prentice-Hall, Englewood Cliffs, New Jersey.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1980

Authors and Affiliations

  • Paul Pritchard
    • 1
  1. 1.Department of Computer ScienceUniversity of QueenslandAustralia

Personalised recommendations