using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
{
int n, i, flag = 0;
Console.Write("Enter
a number to check : ");
n
= int.Parse(Console.ReadLine());
for (i = 2; i <= n / 2; i++)
{
if (n % i == 0)
{
flag = 1;
break;
}
}
if (flag == 0)
Console.WriteLine(n + " is a prime number.");
else
Console.WriteLine(n + " is not a prime number.");
Console.ReadKey();
}
}
}

No comments:
Post a Comment