STEP 1 : start STEP 2 : print "enter a number" STEP 3 : take input of number in e STEP 4 : int n=num, int rev =0 STEP 5 : repeat STEP to STEP until n>0 STEP 6 : int d=n%10 STEP 7 : rev=(rev*10)+d STEP 8 : n=n/10 STEP 9 : int p= input value from STEP 13 STEP 10 : int d=0, x=num STEP 11 : int i=2, repeat STEP 12 until i<=x/2, i++ STEP 12 : if (x/i==0) then d=1; break STEP 13 : return d STEP 14 : input value in q from STEP 18 STEP 15 :int d=0, x=rev STEP 16 : int i=2, repeat STEP 12 until i<=x/2, i++ STEP 17 : if (x/i==0) then d=1; break STEP 18 : return d STEP 19 : if (p==1&&q==1) then goto STEP 20 else goto STEP 21 STEP 20 : print num+" is an emirp number" STEP 21 : print num+" is not an emirp number" STEP 22 : end |
{
int num;
int rev;
emrip()
{
}
emrip(int nn)
{
num=nn;
}
int isPrime(int x)
{
int d=0;
for(int i=2;i<=x/2;i++)
{
if(x%i==0)
{
d=1;
break;
}
}
return d;
}
void isEmrip()
{
int n=num;
rev=0;
while(n>0)
}
int d=n%10;
rev=(rev*10)+d;
n=n/10;
}
emrip obj=new emrip();
int p=obj.isPrime(num);
int q=obj.isPrime(rev);
if(p==1&&q==1)
System.out.println(num+" is an emirp number");
else
System.out.println(num+" is not an emirp number");
}
public static void main(String[] arg)
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a number");
int e=sc.nextInt();
emrip obj=new emrip(e);
obj.isEmrip();
}
}
If you find helpful please share
Comments
Post a Comment