Design a site like this with
Get started

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 .

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() {
reverse = reverse * 10 + original % 10
num = num / 10
// comparing the reversed number to the original one
print(“\(original) is a Palindrome number.”)
print(“\(original) is not a Palindrome number.”)
// calling the function finally

To get the source code, visit Farial Mahmod Tishan’s github at:


Published by Farial Mahmod Tishan

Life-long learner. Developing Flutter apps on Parrot Linux OS .

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: