BitArray
素数
class Program { public static void GenPrimes(int[] arr) { bool flag = true; for (int i = 2; i < arr.Length; i++) { for (int j = i+1; j < arr.Length; j++) { if (arr[j]!=0) { if (j%i==0) { arr[j] = 0; } } } } } public static void ShowPrimes(int[] arr) { for (int i = 2; i < arr.Length; i++) { if (arr[i]!=0) { Console.Write(i+" "); } } Console.WriteLine(); } static void Main(string[] args) { int size = 100; int[] arr = new int[100]; for (int i = 0; i <=size-1; i++) { arr[i]=i; } // ShowPrimes(arr); GenPrimes(arr); ShowPrimes(arr); Console.ReadLine(); } }