-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimes.java
More file actions
43 lines (43 loc) · 882 Bytes
/
Primes.java
File metadata and controls
43 lines (43 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.*;
class Primes
{
public static void main(String[] args)
{
int n1,n2,i,temp=0,rem=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter First Number -");
n1=sc.nextInt();
System.out.print("Enter Second Number -");
n2=sc.nextInt();
if(n1==0 || n1==1)
System.out.print(n1+ " neither Prime nor Composite.");
else if(n1==0 || n1==1)
System.out.print(n1+ " neither Prime nor Composite.");
for(i=2;i<=n1/2;i++)
{
if(n1%i==0)
{
temp=1;
break;
}
}
if(temp==0)
System.out.print(n1+" is Prime.");
else
System.out.print(n1+" is not Prime.");
if(temp==1)
System.out.print(n2+" is Prime.");
else
System.out.print(n2+" is not Prime.");
if(n1>n2)
{
rem=n1%n2;
System.out.print("Reminder is "+rem);
}
else
{
rem=n2%n1;
System.out.print("Reminder is "+rem);
}
}
}