for example if input 23 is given
Output of the program should be 0,1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,101,111,121,131(first 23 pallindrome numbers)
i have done simple pallindrome check but could not put in nested loops.
for example if input 23 is given
Output of the program should be 0,1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,101,111,121,131(first 23 pallindrome numbers)
i have done simple pallindrome check but could not put in nested loops.
Do you know how to check if a number is palindrome or not?
Hello Kai1
Thank you.
i just got,how to do it i made a silly mistake in loop logic now i found it and corrected it.
Sorry for posting such a trivial question i am new to coding XD.
Here are the solution
Python 3 Code (while pasting indentation is missed sorry for that)
'''
Print 1st n pallindrome numbers
'''
n=int(input("how many pallindrome nos you want:\n"))
count=1
reverse=0
n1=0
temp=0
while count<=n:
reverse=0
temp=n1
while temp:
rem=temp%10
temp//=10
reverse=reverse*10+rem
if(n1==reverse):
print(n1,end =" ")
count=count+1
n1=n1+1
C code :
#include<stdio.h>
int main()
{
long long unsigned int n,count=1,reverse,n1=0,temp,rem=0;
printf("enter how many pallindrome numbers:\n");
scanf("%llu",&n);
while(count<=n)
{
reverse=0;
temp=n1;
while(temp)
{
rem=temp%10;
temp/=10;
reverse=reverse*10+rem;
}
if(n1==reverse)
{
printf("%llu ",reverse);
count++;
}
n1++;
}
return 0;
}
Thanks
Ramesh Varma