I have 4 different commands in LOOP programming language:

    y=Val(x)=copy x and put it in register y

Finally I also have

    loop n times {

How is it possible that there is an equivalent loop program to every other loop program which uses only Inc, Zero and the loop?

For me it is not clear how to express the Dec-command using only Inc, Zero and the loop.


1 Answer 1


Here's one way to code y=Dec(x):

loop x times {
  loop z times {
  • Thank you. I am little bit confused concerning the double loop. What exactly means. z=Zero() loop x times { loop y times { z=Inc(z) } } Does this describe a function g(x,y)=x+y ?
    – Voyage
    Commented Mar 10, 2013 at 14:58
  • The inner loop in my code just does y=y+z. Your example says “increase z y times (i.e., z=z+y), and do that x times, (i.e., z=z+x*y).” Commented Mar 10, 2013 at 16:11
  • Oh, and in case wonder why my code performs Dec: In the first iteration of the outer loop, z is zero, so the inner loop does nothing. In the remaining x-1 iterations, z=1, so y starts at 0 and is increased x-1 times. Commented Mar 10, 2013 at 16:14
  • ...and how do you obtain a negative number using this method? If X = 0, the result will not be -1. Commented Mar 10, 2013 at 17:51
  • Loop doesn't have negative numbers. x=Zero(); x=Dec(x); makes x equal zero, according to the language web page (and the wikipedia page linked above). Otherwise, you're of course right. Commented Mar 10, 2013 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.