-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
35 lines (32 loc) · 772 Bytes
/
Main.java
File metadata and controls
35 lines (32 loc) · 772 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
/* Online Java Compiler and Editor */
import java.util.Scanner;
public class Main {
public static void main(String []args) {
Primes(1, 100000);
}
public static void Primes(int a, int b) {
for (int i = a+1; i < b; i++) {
if(isPrime(i) == true){
System.out.println(i);
}
}
}
public static boolean isPrime(int n){
boolean res = false;
int count = 0;
for (int i = 1; i*i <= n ; i++) {
if(n%i == 0){
if(i!=n/i){
count+=2;
}
else{
count++;
}
}
}
if(count == 2){
res = true;
}
return res;
}
}