-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2Prime.java
More file actions
51 lines (51 loc) · 974 Bytes
/
2Prime.java
File metadata and controls
51 lines (51 loc) · 974 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
44
45
46
47
48
49
50
51
import java.util.*;
class 2Prime
{
public static void main(String[] args)
{
int n1,n2,i,temp1=0,temp2=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)
{
temp1=1;
break;
}
}
if(temp1==0)
System.out.print(n1+" is Prime.");
else
System.out.print(n1+" is not Prime.");
for(i=2;i<=n2/2;i++)
{
if(n2%i==0)
{
temp2=1;
break;
}
}
if(temp2==0)
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);
}
}
}