Go - Palindrome Program Example
If a number/string, which when read in both forward and backward way is the same, then such a number is called a palindrome number. Example 1. Go Program to check whether the given number is Palindrome or not //Check Whether a Number is Palindrome or Not package main import "fmt" // Main function func main() { number1 := 121 number2 := 125 number3 := 125521 IsPalindrome(number1) IsPalindrome(number2) IsPalindrome(number3) } func IsPalindrome(number int ) { var lastDigit int sum := 0 a := number // Code to reverse a number for a != 0 { lastDigit = a % 10 //getting remainder sum = (sum * 10 ) + lastDigit a = a / 10 } /*If given number equal to sum than number is palindrome otherwise not palindrome*/ if sum == number { fmt.Println(number, " is palindrome " ) } else { fmt.Println(number, " is not palindrome" ) } } Output: Example 2. Go Progra