WAP in java that displays the first 100 palindromic prime numbers
Answers
Answer:
public class PalindromicPrime { public static void main(String[] args) { final int total = 100; final int displayPerLine = 10; int count = 1; int number = 2; while (count <= total) { if (isPrime(number) && isPalindrome(number)) { System.out.print(number + " "); if (count % displayPerLine == 0) System.out.println(); count++; } number++; } } /* Test if the number is Prime */ public static boolean isPrime(int num)
Hope this helps you
Answer:
Explanation:
public class PalindromicPrime { public static void main(String[] args) { final int total = 100; final int displayPerLine = 10; int count = 1; int number = 2; while (count <= total) { if (isPrime(number) && isPalindrome(number)) { System.out.print(number + " "); if (count % displayPerLine == 0) System.out.println(); count++; } number++; } } /* Test if the number is Prime */ public static boolean isPrime(int num)