Write a c# program to check prime number.



using System;

public class PrimeNumber
{
    public static bool IsPrime(int number)
    {
        if (number <= 1)
        {
            return false;
        }

        for (int i = 2; i <= Math.Ceiling(number / 2); i++)
        {
            if (number % i == 0)
            {
                return false;
            }
        }

        return true;
    }

    public static void Main(string[] args)
    {
        int number = 13;

        if (IsPrime(number))
        {
            Console.WriteLine("The number {0} is a prime number.", number);
        }
        else
        {
            Console.WriteLine("The number {0} is not a prime number.", number);
        }
    }
}
Write a c# program to check prime number. Write a c# program to check prime number. Reviewed by Bhaumik Patel on 8:34 PM Rating: 5