using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { while (true) { Console.Write("请输入数字a="); int a = int.Parse(Console.ReadLine()); int num = 0; for (int i = 1; i <= num; i++) { double b = a % i; if (b == 0) { num++; } } if (num == 2) { Console.WriteLine("你输入的{0}是质数", a); } else { Console.WriteLine("你输入的{0}不是质数", a); } Console.ReadLine(); } } } }