-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimenumber.java
More file actions
42 lines (39 loc) · 1005 Bytes
/
Copy pathPrimenumber.java
File metadata and controls
42 lines (39 loc) · 1005 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
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n,count=0;
System.out.println("Enter n value\n");
n=s.nextInt();
int[]array=new int[n];
System.out.println("Enter elments:");
for(int i=0;i<n;i++)
{
array[i]=s.nextInt();
}
for(int i=0;i<n;i++)
{
int factors=0;
int number=array[i];
if(number<=1)
{
continue;
}
else
{
for(int j=1;j<=number;j++)
{
if(number%j==0)
{
factors++;
}
}
}
if(factors==2)
{
count++;
}
}
System.out.println(count);
}
}