program Gray Code // Input: Integer n (0 - E) from standard input. // Output: Gray code of order n to standard output. // ----------------------------------------------------------------------------- // Initialize 10: 8AFF read RA n = StdIn.readInt() 11: 7101 R1 <- 1 always 1 12: 5B1A RB <- 1 << RA i = 2^n while (i != 0) { 13: 2BB1 RB <- RB - 1 i = 2^n - 1 14: 6CB1 RC <- RB >> R1 c = (i >> 1) 15: 4DBC RD <- RB ^ RC d = i ^ (i >> 1) 16: 9DFF write RD print RD 17: DB13 if (RB > 0) pc <- 13 } 18: 0000 halt