A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Palindromic Number in Go page! Here, you'll find the source code for this program as well as a description of how the program works.
package main
import (
"fmt"
"os"
"strconv"
)
func palindromicNumber(x int) {
if x >= 0 {
reversedNumber := 0
noOfDigits := 0
temp := x
for temp > 0 {
noOfDigits++
reversedNumber = (reversedNumber * 10) + (temp % 10)
temp /= 10
}
if x == reversedNumber {
fmt.Println("true")
} else {
fmt.Println("false")
}
} else {
fmt.Println("Usage: please input a non-negative integer")
}
}
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: please input a non-negative integer")
os.Exit(1)
}
x, err := strconv.Atoi(os.Args[1])
if err != nil {
fmt.Println("Usage: please input a non-negative integer")
os.Exit(1)
}
palindromicNumber(x)
}
Palindromic Number in Go was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.