using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
int n, i,flag=0;
Console.WriteLine("Enter No. : ");
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();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
int n, i,flag=0;
Console.WriteLine("Enter No. : ");
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