02.PrimeChecker

using System;
using System.Numerics;

class Prime
{
    static void Main()
    {
        Console.Write("Enter a positive integer number: ");
        BigInteger number =BigInteger.Parse(Console.ReadLine());
        Console.WriteLine("\n");

        IsPrimeCheck(number);
    }
        static bool IsPrime(BigInteger num)
        {
            bool prime = true;
            if (num == 1 || num == 0)
            {
                prime = false;
                return prime;
            }
            double divider = 2;
            double maxDivider = Math.Sqrt((double)num);
            while (prime && (divider <= maxDivider))
            {
                if ((double)num % divider == 0)
                {
                    prime = false;
                }
                divider++;
            }
            return prime;
        }
        static void IsPrimeCheck(BigInteger num)
        {
            bool prime = IsPrime(num);
            if (num < 0)
            {
                Console.WriteLine("Invalid exception!");
                Console.WriteLine("\n");
                return;
            }
            else
            {
                Console.WriteLine("Is Prime? {0}", prime);
                Console.WriteLine("\n");
            }
        }
    
}