We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d3c55c commit 75a94fcCopy full SHA for 75a94fc
1 file changed
Number Theory/PalPrime.java
@@ -0,0 +1,35 @@
1
+//Write a program to check a number for palindrome prime.
2
+public class PalPrime
3
+{
4
+ static boolean isPalPrime(int num)
5
+ {
6
+ int d = 1; /// Find the appropriate d (divisor)
7
+ while (num / d >= 10)
8
+ d *= 10;
9
+
10
+ while (num != 0)
11
12
+ int leading = num / d;
13
+ int trailing = num % 10;
14
15
+ if (leading != trailing) // If first and last digit
16
+ return false; // not same return false
17
18
19
+ num = (num % d) / 10; // number find from digit
20
21
22
+ d = d / 100; // Reducing divisor
23
24
+ }
25
+ return true;
26
27
28
+ public static void main(String args[])
29
30
+ if(isPalPrime(16461))
31
+ System.out.println("Yes, Number is Palindrome");
32
+ else
33
+ System.out.println("No, Number is not Palindrome");
34
35
+}
0 commit comments