Write a program to find highest prime number in given
range.
Find highest prime number
in given range using java.
// highest prime number in given range
import
java.io.*;
public class
highestprimenumber {
public static void
main(String[]args)throws IOException
{
int
num1,num2,i,a=0,count,j;
BufferedReader br=new
BufferedReader (new InputStreamReader (System.in));
System.out.println("enter
the range from where to next u want highest prime number");
num1=Integer.parseInt(br.readLine());
num2=Integer.parseInt(br.readLine());
for(i=num2;i>num1;i--)
{
count=0;
for(j=2;j<i;j++)
{
a=i%j;
if(a==0)
{
count++;
}
}
if(count==0)
{
System.out.print("highest
prime number between the given range is: "+i);
break;
}
}
}
}
No comments:
Post a Comment