by Dinesh Thakur Category: Control Structures

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;
                         if(num% j==0)
                           return i;

Highest Prime Number Within the Given Range

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles