From feeb934df9a55602a0c038f3b73e948c6a6c6e06 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Sun, 3 Dec 2023 02:19:42 -0500 Subject: 9,1266 --- 9/main.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 9/main.go (limited to '9') diff --git a/9/main.go b/9/main.go new file mode 100644 index 0000000..cc44567 --- /dev/null +++ b/9/main.go @@ -0,0 +1,23 @@ +package main + +import "fmt" + +func isPalindrome(x int) bool { + if x < 0 { + return false + } + var y int + for i := x; i > 0; i /= 10 { + y = y*10 + i%10 + fmt.Println(y) + } + return x == y +} + +func main() { + fmt.Println(isPalindrome(12345678)) + fmt.Println(isPalindrome(1234321)) + fmt.Println(isPalindrome(121)) + fmt.Println(isPalindrome(-121)) + fmt.Println(isPalindrome(10)) +} -- cgit v1.2.3