Write a java program to find the EMIRP number🔢
EMIRP NUMBER: is a number which is prime backward and forwards.
Eg: 79
79 is a prime number
AND
97 which is the reverse of 79 is also a prime number
PRIME NUMBER: is a number which is divisible only by 1 and itself
Eg: 2,3,5,7,11 etc
import java.util.* ;
public class EMIRP {
int n,nm, q=0,p=0,rev=0,count =0;
EMIRP(int nm)
{
n=nm;
rev=0;
}
int isPrime(int x)
{
for(int i=1;i<=x;i++)
{
if(x%i==0)
count++;
}
if(count<=2)
return 1;
else
return -1;
}
void isEMIRP()
{
while(nm>0)
{
int d=nm%10;
rev=rev*10+d;
nm=nm/10;
}
for(int i=1;i<=n;i++)
{
if(n%i==0)
p++;
}
if(p<=2)
{
for(int i=1;i<=rev;i++)
{
if(rev%i==0)
q++;
}
if(q<=2)
System.out.println(n+ " IS AN EMIRP NUMBER ");
}
else
System.out.println(n+ " IS NOT AN EMIRP NUMBER ");
}
public static void main(String[] args) {
EMIRP ob = new EMIRP(79);
ob.isPrime(7);
ob.isEMIRP();
}
}
FOR CODE : CLICK >> https://onecompiler.com/java/3ygrytab5 TO FIND OUTPUT
SUPPORT US >> https://onethoughttechnology.blogspot.com (OFFICIAL WEBSITE)