A First Example

  • Niklaus Wirth
Part of the Text and Monographs in Computer Science book series (MCS)

Abstract

Let us follow the steps of development of a simple program and thereby explain some of the fundamental concepts of programming and of the basic facilities of Modula. The task shall be, given two natural numbers x and y, to compute their greatest common divisor (gcd). The mathematical knowledge needed for this problem is the following:
  1. 1.

    if x equals y, x (or y) is the desired result

     
  2. 2.

    the gcd of two numbers remains unchanged, if we replace the larger number by the difference of the numbers, i.e. subtract the smaller number form the larger one.

     

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer-Verlag Berlin Heidelberg 1988

Authors and Affiliations

  • Niklaus Wirth
    • 1
  1. 1.Institut für InformatikETHZürichSwitzerland

Personalised recommendations