Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Tuhin committed Mar 31, 2018
1 parent 0ac6d63 commit 4dffc60
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Day25RunningTimeAndComplexity
{
class Program
{
static void Main(String[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
int[] a = new int[n];
for(int i = 0; i < n; i++)
{
a[i] = Convert.ToInt32(Console.ReadLine());
}


foreach(int i in a)
{
if (isPrime(i))
{
Console.WriteLine("Prime");
}
else
{
Console.WriteLine("Not Prime");
}
}

Console.ReadKey();
}
public static bool isPrime(int n)
{
if (n == 2)
{
return true;
}
if (n == 1 || n % 2 == 0)
{
return false;
}
for (int i = 3; i * i <= n;)
{
if (n % i == 0)
{
return false;
}
i += 2;
}
return true;
}
}
}

0 comments on commit 4dffc60

Please sign in to comment.