/*** @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 herem := 0b := toBinary(n)tmp := bfor tmp > 0 {m = tmp % 10 + m * 10tmp /= 10}return m == b}func toBinary(n int) int {i := 0b := 0for n > 0 {b = (n % 2) * pow(10,i) + bi++n /= 2}return b}func pow(n,k int) int {res := 1for i := 0; i < k; i++ {res *= n}return res}
