An Emirp (prime spelled backward) is a prime number whose reversal is also a prime. For example, 17 is a prime 71 is a prime. So 17 and 71 are emirps. Write a program that displays the first 100 emirps. Display 10 numbers per line and align the numbers properly.
import java.util.*; public class Exercise05_27{ public static void main(String[] args){ {int number=12,number2,upto=0,i; int[] prime=new int[100]; while(upto<100) {if(!check(number,prime,upto)) if(isPrime(number)) {number2=reverse(number); if(number2!=number) if(!check(number2,prime,upto)) if(isPrime(number2)) upto=insert(number,number2,prime,upto); } number++; } sort(prime,upto); System.out.println("The first 100 EMIRP numbers are:"); for(i=0;i {if(i%10==0) System.out.println(); System.out.printf("%7d",prime[i]); } } } public static void sort(int a[],int n) {int i,j,t; for(i=0;i for(j=i;j if(a[i]>a[j]) {t=a[i]; a[i]=a[j]; a[j]=t; } } public static boolean check(int n,int a[],int c) {int i; for(i=0;i if(a[i]==n) return true; return false; } public static int insert(int n,int m,int a[],int i) { a[i++]=n; a[i++]=m; return i; } public static int reverse(int n) {int newnum=0; while(n>0) {newnum=newnum*10+n%10; n=n/10; } return newnum; } public static boolean isPrime(int n) {int i; for(i=2;i if(n%i==0) false;