Check if a number is prime. From Fundamentals of Computer Programming with C# http://www.introprogramming.info/wp-content/uploads/2013/07/Books/CSharpEn/Fundamentals-of-Computer-Programming-with-CSharp-Nakov-eBook-v2013.pdf
int divider = 2;
bool prime = true;
Console.Write("Enter a positive number: " );
int num = int.Parse(Console.ReadLine());
int maxDivider = (int) Math.Sqrt(num);
while (prime && (divider <= maxDivider))
{
if (num % divider == 0)
{
prime = false;
}
divider++;
}
Console.WriteLine( "Prime? " + prime);
// Enter a positive number: 4
// Prime? False
// Enter a positive number: 11
// Prime? True