You are given a decimal number n. You need to find the gray code of the number n and convert it into decimal.
To see how it's done, refer here.
The first line contains an integer T, the number of test cases. For each test case, there is an integer n denoting the number
For each test case, the output is gray code equivalent of n.
1 <= T <= 100
0 <= n <= 108
Testcase1: 7 is represented as 111 in binary form. The gray code of 111 is 100, in the binary form whose decimal equivalent is 4.
Testcase2: 10 is represented as 1010 in binary form. The gray code of 1010 is 1111, in the binary form whose decimal equivalent is 15.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.