import java.io.*;
class Prime
{
static int isPrime(int n)
{
int i, c = 0;
for (i = 1; i < n; i++) {
if (n % i == 0)
c++;
}
if (c == 1)
return 1;
else
return 0;
}
public static void main(String[] arg) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number::");
int n = Integer.parseInt(br.readLine());
int i;
for (i = 2; i < n; i++)
{
if (isPrime(i) == 1)
System.out.print(i + "\n");
}
}
}
OUTPUT::
Enter the number::12
2
3
5
7
11
class Prime
{
static int isPrime(int n)
{
int i, c = 0;
for (i = 1; i < n; i++) {
if (n % i == 0)
c++;
}
if (c == 1)
return 1;
else
return 0;
}
public static void main(String[] arg) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number::");
int n = Integer.parseInt(br.readLine());
int i;
for (i = 2; i < n; i++)
{
if (isPrime(i) == 1)
System.out.print(i + "\n");
}
}
}
OUTPUT::
Enter the number::12
2
3
5
7
11