import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Prime {
public static void main(String args[]) throws IOException {
int n, count, c = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter A Value : ");
n = Integer.parseInt(br.readLine());
System.out.println("Prime Numbers up to " + n);
for (int i = 2; i <= n; i++) {
count = 2;
for (int j = 2; j < i; j++) {
if (i % j == 0)
count++;
}
if (count == 2) {
System.out.print(i + " ");
c++;
}
}
}
}
OUTPUT:
Enter A Value :
100
Prime Numbers up to 100
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97