Design a site like this with WordPress.com

# Palindrome Number in Swift

A Palindrome number is a special type of number that reads the same if read in reverse . Problems relating to Palindrome are common in both programming and mathematics . We shall implement a program to implement Palindrome number in Swift language .

A short note on Swift: Swift is an open-source programming language developed by Apple Inc. to make apps for iOS, MacOS, tvOS & watchOS .

Steps:
1. Taking a variable to store a number (to test if that number is Palindrome) and another variable assuming as the reverse number (initially as Flag Variable, 0)
2. Reversing the original (or, taken as user-input)
3. If the reversed number equals to the original number, it is a Palindrome – otherwise not .

Program to implement Palindrome number in Swift language:

var reverse = 0
// original is the variable to be tested whether it is Palindrome or not
// you may change it
var original = 1111
var num = original
func rever() {
while(num>0){
reverse = reverse * 10 + original % 10
num = num / 10
}
// comparing the reversed number to the original one
if(original==reverse){
print(“\(original) is a Palindrome number.”)
}
else{
print(“\(original) is not a Palindrome number.”)
}
}
// calling the function finally
rever()

To get the source code, visit Farial Mahmod Tishan’s github at:
https://github.com/Farial-mahmod/Palindrome-number-in-Swift