/**
* @param n: non-negative integer n.
* @return: return whether a binary representation of a non-negative integer n is a palindrome.
*/
func IsPalindrome (n int) bool {
// Write your code here
m := 0
b := toBinary(n)
tmp := b
for tmp > 0 {
m = tmp % 10 + m * 10
tmp /= 10
}
return m == b
}
func toBinary(n int) int {
i := 0
b := 0
for n > 0 {
b = (n % 2) * pow(10,i) + b
i++
n /= 2
}
return b
}
func pow(n,k int) int {
res := 1
for i := 0; i < k; i++ {
res *= n
}
return res
}