A prime number can be divided only by
itself or by 1 that number is called prime number.
For Example : The number 3 can be
divided only by 3 or by 1 that means we say that the number 3 is a prime
member.
Noted point: The
number 0 and 1 are not considered prime numbers.
Prime Numbers : 2, 3, 5,
7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61..
I am going to share the example using
Asp.Net C# as given below.
class PrimeNumber
{
static void Main(string[] args)
{
bool IsPrimeNum = true;
Console.WriteLine("Please enter
numbers for get prime number. ");
long number = Convert.ToInt32(Console.ReadLine());
for (long p = 2; p <=
number; p++)
{
for (long q = 2; q <=
number; q++)
{
if (p != q &&
p % q == 0)
{
IsPrimeNum = false;
break;
}
}
if (IsPrimeNum)
{
Console.WriteLine(p);
}
IsPrimeNum = true;
}
Console.ReadLine();
}
}