second method to recursively generate Gray Code