aboutsummaryrefslogtreecommitdiffstats
path: root/9
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--9/main.go23
1 files changed, 23 insertions, 0 deletions
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))
+}