/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 408 - Problem 7: Is Prime (a) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static bool IsPrime(int n) { for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; } static void Main(string[] args) { int x; Console.Write("Please enter a number: "); x = int.Parse(Console.ReadLine()); if (IsPrime(x)) Console.WriteLine("\n\n{0} is prime", x); else Console.WriteLine("\n\n{0} is NOT prime", x); Console.ReadKey(); } } }