Return to Snippet

Revision: 63322
at April 25, 2013 18:31 by jholderman


Initial Code
static bool isPrime(int number)
        {

            if (number == 1) return true;
            if (number == 2) return true;
            if (number == 3) return true;
            if (number == 4) return false;

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

            return true;

        }

Initial URL

                                

Initial Description
Method to Check if an int is a Prime Number

Initial Title
Is this Number Prime

Initial Tags
number

Initial Language
C#