Turn Desktop View Off
by Dinesh Thakur

Algorithm For Prime Numbers between Range:

step 1: Set num=1

step 2: Read range

step 3: Repeat through step-9 while num less than or equals to range

step 4: Initialize b= 1, c=0

step 5: Repeat through step-7 while b less than or equals to num

step 6: If (num mod b) equals to 0 then set c=c+1

step 7: b=b+1

step 8: If c equals to 2 then print num

step 9: num =num +1

step 10: Exit

Here is the Java Example for Prime Numbers between Range:

import java.util.Scanner;

public class PrimeNumberBetweenRange
{
                  public static void main(String args[])
          {
                   int num =1,b,c,range;
                 Scanner s=new Scanner(System.in);
                 System.out.println("Enter The Range \n");
                 range=s.nextInt();
                 while(num <=range)
                       {
                           b=1;
                           c=0;
                           while(b<= num)
                                {
                                  if((num%b)==0)
                                    c=c+1;
                                    b++;
                                }
                                   if(c==2)
                      System.out.println(num +" is a prime number");
                                    num ++;
                        }
             }
}

Prime Numbers between Range