訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.Write("2 is prime\n"); for (int p = 3; p <= 1000; p+=2) { bool Is = true; for (int i = 2; i <= Math.Sqrt((double)p); i++) if (p % i == 0) { Is = false; break; } if (Is) Console.Write(p + " is prime\n"); } Console.ReadLine(); } } }