Prime numbers/Program/Only addition/Exercise

From Wikiversity
Jump to navigation Jump to search

Write a computer-program (in pseudocode) which decides for a given natural number whether is a prime number or not.

    • The computer has as many memory units as needed, which can contain natural numbers.
    • It can empty memory units.
    • It can increase the content of a memory unit by .
    • It can add the content of two memory units and write the result into another memory unit.
    • It can compare the content of memory units and can, depending on the outcome, switch to a certain program line.
    • It can print contents of memory units and it can print given texts.
    • There is a stop command.

The initial configuration is

with .

The program is supposed to print " is a prime number“ or " is not a prime number“ and then stop.