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) { // Rastgele sayı üreteci oluşturun Random rnd = new Random(); // Listbox'ları oluşturun List listbox1 = new List(); List listbox2 = new List(); List listbox3 = new List(); List listbox4 = new List(); // Rastgele sayılar üretin ve listbox'lara ekleyin for (int i = 0; i < 100; i++) { int sayi = rnd.Next(1, 1000); listbox1.Add(sayi); if (sayi % 2 == 0) { listbox2.Add(sayi); } else { listbox3.Add(sayi); } if (IsPrime(sayi)) { listbox4.Add(sayi); } } // Listbox'ları ekrana yazdırın Console.WriteLine("Listbox 1: "); foreach (int s in listbox1) { Console.Write(s + " "); } Console.WriteLine(); Console.WriteLine("Listbox 2 (çift sayılar): "); foreach (int s in listbox2) { Console.Write(s + " "); } Console.WriteLine(); Console.WriteLine("Listbox 3 (tek sayılar): "); foreach (int s in listbox3) { Console.Write(s + " "); } Console.WriteLine(); Console.WriteLine("Listbox 4 (asal sayılar): "); foreach (int s in listbox4) { Console.Write(s + " "); } Console.WriteLine(); Console.ReadLine(); } // Asal sayı olup olmadığını kontrol eden fonksiyon static bool IsPrime(int number) { if (number <= 1) return false; if (number == 2) return true; if (number % 2 == 0) return false; int boundary = (int)Math.Floor(Math.Sqrt(number)); for (int i = 3; i <= boundary; i += 2) { if (number % i == 0) return false; } return true; } } }