Solution to Gray Code Iterative