It is necessary to fill an array of a given length with various primes. Here is the under-realization curve (details in the comments):
class Program { static void Main(string[] args) { int[] arr = new int[10]; Work ob = new Work(); ob.Go(arr); Console.ReadLine(); } } class Work { public void Go(int[] arr) { int temp = 2; for(int i = 0; i < arr.Length; i++) { if (i == 0) { arr[i] = temp; continue; } if (i == 1) { arr[i] = (temp = temp + 1); temp++; continue; } if ((1 == (temp / temp)) && ((temp / 1) == temp)) { //это проверка на "простое ли число" (ошибочна) не хватает условия "которое не делится без остатка ни на одно другое целое положительное число" // поэтому всё решение и разваливается. Собственно, как это реализовать??? arr[i] = temp; temp++; } } for(int j = 0; j < arr.Length; j++) { Console.WriteLine(arr[j]); } } }
(1 == (temp / temp)) && ((temp / 1) == temp)- and what happens differently? - Igor