Jump to content

Program/Two registers/Bijective mapping/Exercise

From Wikiversity

We consider a computer with only two memory units, each can represent a natural number. At the start of every program (a sequence of commands), the initial entries are . The computer can empty a memory unit, it can increase a memory unit by , it can jump to another command (unconditional Goto) and it can compare the two entries of the two memory units. Moreover, it can jump to another command in case the comparing condition is fulfilled (conditional Goto). There is a printing command which prints the entries at the moment. Write a computer-program such that every pair is printed exactly once.