Gray Code Value
PHP
Hard
5 views
Problem Description
Input n. Print gray code g = n ^ (n>>1).
Input Format
One integer n.
Output Format
One integer g.
Official Solution
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
$n=intval($inputText);
echo ($n ^ ($n>>1));
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!