You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
285 B
19 lines
285 B
2 years ago
|
package palindromenumber
|
||
|
|
||
|
import "strconv"
|
||
|
|
||
|
func isPalindrome(x int) bool {
|
||
|
str := strconv.Itoa(x)
|
||
|
for i, digit := range str {
|
||
|
if byte(digit) != str[len(str)-i-1] {
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
// public for test
|
||
|
func IsPalindrome(x int) bool {
|
||
|
return isPalindrome(x)
|
||
|
}
|