Receptionist gives an integer number and says that find the two nearest prime number of that number and find the product .the last two digit of product is the room number of Harsh.
Help the Anuj to find his brother's Room number.

Input

30

Output

Room number Harsh

Solution

import java.util.*;
class TestClass {
public static void main(String args[] ) throws Exception {
Scanner s = new Scanner(System.in);
int n=s.nextInt();
int i,k,j,c=0;
for(i=n+1;i<1000;i++)
{c=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==0)
{
break;
}
}
for(k=n-1;k>0;k--)
{c=0;
for(j=2;j<k;j++)
{
if(k%j==0)
{
c++;
}
}
if(c==0)
{
break;
}
}
int pro=i*k%100;
System.out.println(""+pro);
}

}



if you have any problem in this code, take a screen shot and contact with Rishabh Chaubey.

Post a Comment

Previous Post Next Post