-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday25.cs
More file actions
35 lines (32 loc) · 773 Bytes
/
Copy pathday25.cs
File metadata and controls
35 lines (32 loc) · 773 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
using System;
using static System.Console;
class Solution
{
static void Main(String[] args)
{
int n = Convert.ToInt32(ReadLine());
int[] numbers = new int[n];
for (int i = 0; i < n; i++)
numbers[i] = Convert.ToInt32(ReadLine());
foreach (int num in numbers)
{
if (IsPrime(num) == true)
WriteLine("Prime");
else
WriteLine("Not prime");
}
ReadKey();
}
public static bool IsPrime(int n)
{
if (n <= 1)
return false;
double tmp = Math.Ceiling(Math.Sqrt(n));
for (int i = 2; i < tmp; i++)
{
if (n % i == 0)
return false;
}
return true;
}
}