Function to chek if the binary representation of a number is a palindrome that uses O(1) space overhead