Gray to Binary equivalent
Submissions: 1424   Accuracy:

56.18%

  Difficulty: Basic   Marks: 1
Associated Course(s):   Sudo Placement 2019

Given N in Gray code equivalent. Find its binary equivalent.

Input:
The first line contains an integer T, number of test cases. For each test cases, there is an integer N denoting the number in gray equivalent.

Output:
For each test case, in a new line, the output is the decimal equivalent number N of binary form.

Constraints:
1 <= T <= 100
0 <= n <= 108

Example:
Input

2
4
15
Output
7
10

Explanation:
Testcase1. 
4 is represented as 100 and its binary equivalent is 111 whose decimal equivalent is 7.
Testcase2. 15 is represented as 1111 and its binary equivalent is 1010 i.e. 10 in decimal.

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: Vanshika_pec


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.