Algorithm for Highest Prime Number:
step 1: Read num
step 2: Set i== 1
step 3: Initialize j==2
step 4: Repeat through step-7 while j less than or equals to num
step 5: If j equals to num then Set i==num and goto 8
step 6: If (num mod)) equals to 0 then num==num-1
step 7: j==j+1
step 8: Print i
Step 9: Exit
Here is the Java Example for Highest Prime Number:
public class HighestNumberRange
{
public static void main(String args[])
{
int i=prime(100);
System.out.println("value of highest prime is :-"+i);
}
public static int prime(int num)
{
int i=1;
for(int j=2;j<=num;j++)
{
if(j== num)
{
i= num;
break;
}
if(num% j==0)
{
num--;
}
}
return i;
}
}