Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Check Palindrome Without Built-in Functions
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
s = input().strip()
rev = ""
# checking the palindrome of a number

for ch in s:
rev = ch + rev
def palindrome(num):
if num==0 or (num%10==0 and num!=0): # checks if the number is not zero and it is not multiple of 10.
return False

print("Palindrome" if s == rev else "Not Palindrome")
rev=0
while num > rev:
rev = rev*10+num%10 # adds the number in reverse order
num=num//10 # decreases the number
return num==rev or num==rev//10