checking prime number in c#.net


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Basics
{
class CheckingPrime
{
static void Main()
{
int count = 0;
Console.WriteLine(“enter a number:”);
int number = int.Parse(Console.ReadLine());

for (int a = 1; a <= 10; a++)
{
if (number % a == 0)
{
count++;

}
}
if (count == 2)
{
Console.WriteLine(“is prime”);
}
else
{
Console.WriteLine(“not prime “);

}
Console.ReadLine();
}
}
}

Leave a comment