-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP3.java
More file actions
51 lines (49 loc) · 1013 Bytes
/
P3.java
File metadata and controls
51 lines (49 loc) · 1013 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
class P3
{
public static void main(String[] rga)
{
long s=600851475143l ;
long a[]=new long[40];
long b[]=new long[45];
long j=1;
int i=0;
while(j!=s)
{
if(s%j==0)
{
a[i]=j;
i++;
}
j++;
}
//for(long x:a)
// System.out.println(x);
i=2;
int q=0;
for(long x1:a)
{
int flag=0;
for(i = 2; i <= x1/2; ++i)
{
// condition for nonprime number
if(x1%i == 0)
{
flag = 1;
break;
}
}
if(flag==0)
{
b[q]=x1;
q++;
}
}
long x3=b[0];
for(long x2:b)
{
if(x2>x3)
x3=x2;
}
System.out.println(x3);
}
}