Print Prime or Not Prime for 11.
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
int n = 11;
bool ok = n > 1;
for (int d = 2; d * d <= n && ok; d++)
if (n % d == 0) ok = false;
Console.WriteLine(ok ? "Prime" : "Not Prime");
}
}
Try solving on your own first, then reveal the official answer.
Trial division to sqrt(n).