Palindrome Numbers in a Given Range in Python
A palindromic number is a number that remains the same when its digits are reversed. In other words, it has reflectional symmetry across a vertical axis. The term palindromic is derived from palindrome, which refers to a word whose spelling is unchanged when its letters are reversed.
Program:
rem=0; temp=0
start=int(input("Enter the lower Number"))
end=int(input("Enter the upper Number"))
print("Palindrome numbers between" ,start,"and",end ,"are: ");
for num in range(start,end+1,1):
temp=num;
reverse=0;
while(temp):
rem=temp%10;
temp=temp//10;
reverse=reverse*10+rem;
if(num==reverse):
print(num);
OutPut:
Enter the lower Number1
Enter the upper Number100
Palindrome numbers between 1 and 100 are:
1
2
3
4
5
6
7
8
9
11
22
33
44
55
66
77
88
99
No comments:
Post a Comment