Recursively generate gray code