1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public static void IsPrime(int number) { if (number == 1 || number == 0) { Console.WriteLine(false); return; } if (number == 2) { Console.WriteLine(true); return; } for (int i = 2; i <= (int)Math.Sqrt(number); i++) { if (number % i == 0) { Console.WriteLine(false); return; } } Console.WriteLine(true); } |