Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Java/program-1/Prime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;
public class Prime
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in); //INPUT CLASS
int num1,num2;
System.out.println("Please enter the first number:");
num1=sc.nextInt(); //GET FIRST NUMBER
System.out.println("Please enter the second number:");
num2=sc.nextInt(); //GET LAST NUMBER
System.out.println("Prime number:");
for(int i=num1;i<=num2;i++)
{
int j;
for(j=2;j<i;j++)
{
int n=i%j;
if(n==0)
{
break;
}
}
if(i==j)
{
System.out.print(" "+i);
}
}
}


4 changes: 4 additions & 0 deletions Java/program-1/Prime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Java Program to display prime numbers between a given range.

num1=Holds the First number
num2=Holds the Last number