Associated Course(s):
Sudo Placement 2019

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.

**Input:**

The first line contains an integer **T,** the number of test cases. For each test case, there is an integer **n **denoting the number

**Output:**

For each test case, the output is gray code equivalent of **n.**

**Constraints:**

1 <= T <= 100

0 <= n <= 10^{8}

**Example:
Input**

2

7

10

4

15

**Explanation:
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.

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.

bhatabhi554 | 317 |

hardikJain5 | 306 |

CodeBuddy | 293 |

Akkki111 | 233 |

clone | 230 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

mazumderrohit8 | 1176 |

RemoveTLE | 1144 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4605 |

Quandray | 4444 |

Login to report an issue on this page.