Gray Code Value

Gray Code Value

Hard PHP PHP Operators 20 views
Explanation Complexity

Problem Statement

Input n. Print gray code g = n ^ (n>>1).

Input Format

One integer n.

Output Format

One integer g.

Example

10
15

Constraints

0

Input / Output Format

Input Format
One integer n.
Output Format
One integer g.
Constraints
0

Examples

Input:
10
Output:
15

Example Solution (Public)

PHP
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
$n=intval($inputText);
echo ($n ^ ($n>>1));
?>

Official Solution Code

<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
$n=intval($inputText);
echo ($n ^ ($n>>1));
?>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.