using System;
using System.Collections.Generic;
using System.Text;
namespace primenumberchecking
{
class primeno
{
static void Main(string[] args)
{
int n,i,p,j=0;
Console.WriteLine("\tPRIME NUMBER CHECKING");
Console.WriteLine("\t**********************");
Console.WriteLine("Enter the Number to Check");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
p = n % i;
if (p == 0)
{
j++;
}
}
if (j == 2)
{
Console.WriteLine("Number {0} is a Prime Number", n);
}
else
{
Console.WriteLine("Number {0} is not a Prime Number", n);
}
}
}
}
using System.Collections.Generic;
using System.Text;
namespace primenumberchecking
{
class primeno
{
static void Main(string[] args)
{
int n,i,p,j=0;
Console.WriteLine("\tPRIME NUMBER CHECKING");
Console.WriteLine("\t**********************");
Console.WriteLine("Enter the Number to Check");
n = int.Parse(Console.ReadLine());
for (i = 1; i <= n; i++)
{
p = n % i;
if (p == 0)
{
j++;
}
}
if (j == 2)
{
Console.WriteLine("Number {0} is a Prime Number", n);
}
else
{
Console.WriteLine("Number {0} is not a Prime Number", n);
}
}
}
}
No comments:
Post a Comment