69) Write a program to input a number and
check whether it is Emirp Number
(Twisted Prime) or not?(13 and its
reverse 31,both are prime)
import java.util.*;public class Emirp{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int k = a;int r = 0;int c = 0;for(int i = 1;i<=a;i++){if(a%i==0){c++;}}if(c==2){while(k>0){int d = k%10;r=(r*10)+d;k=k/10;}c=0;for(int i = 1;i<=r;i++){if(r%i==0){c++;}}if(c==2){System.out.println("Entered number is a EMIRP(TWISTED PRIME) Number");}else{System.out.println("Entered number is not a EMIRP(TWISTED PRIME) Number");}}else{System.out.println("Entered number is not a EMIRP(TWISTED PRIME) Number");}}}
Output :
emirp-number Write a program to input a number and
check whether it is Pal Prime Number
or not?(prime and palindrome=131) |