+ 2
Prime Palindrome Numbers.
Write a program to check whether a number is positive Prime Palindrome number or not. https://code.sololearn.com/c36wb799F7qy/?ref=app
7 Respostas
+ 5
No. it printing "all primes polindrome for any prime number. Do you checked for 127, 131 inputs...?
By the way, without using coutdigits function and others extra variable, you can do simply
int toReverse(int a)
{
int size=0,store=a,rev=0,c;
while(store!=0)
{
c=store%10;
rev=rev*10+c;
store/=10;
}
return rev==a ? 1 : 0;
}
This way you can return 1 or 0 either you can return a reversed numbernumber, compare it in calling statement like I posted previously...
Your way always results to even if it not polindrome ...
hope it helps..
+ 3
if( isPrime(num) && (num == toReverse(num)))
+ 2
Saif ali ,
is there any issue with your code, do you have any question?
+ 2
Lothar I wanna minimize this program as short as possible.
1) Is their any way by which I can directly find number of digits of a number?
2) I wanna try Boolean as return type but I am not able to get it right as I used to do in Java.
3) can we use ternary operators in C like '? ' and ':'
+ 1
Jayakrishna🇮🇳 I don't think so what u r saying is correct. Actually the given code is correct, but I wanna minimize it
+ 1
I like it more this way:
doing reverse first, then prime, before SoloLearn timeout it runs to 9280829
swapping to check prime first, then check palindrome only gets to 1883881
https://code.sololearn.com/cBK5MefZPKK9/?ref=app
0
// hope this link helps you
https://code.sololearn.com/cn7bc0Uk3evY