Arithmetic mean/Program/Natural memory unit/Exercise

From Wikiversity
Jump to navigation Jump to search

Write a computer-program (pseudocode) which computes the arithmetic mean of two given non negative rational numbers.

    • The computer has as many memory units as needed, which can contain natural numbers.
    • It can add the content of two memory units and write the result into another memory unit.
    • It can multiply the content of two memory units and write the result into another memory unit.
    • It can print contents of memory units and it can print given texts.
    • There is a stop command.

The initial configuration is

with . Here and represent the rational numbers from which we want to compute the arithmetic mean. The result should be printed (in the form numerator denominator)

and then the program shall stop.