/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 408 - Problem 7: Is Prime (b) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static bool IsPrime(int n) { for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; } static void Main(string[] args) { int x, y; Console.Write("Please enter first number: "); x = int.Parse(Console.ReadLine()); Console.Write("Please enter second number: "); y = int.Parse(Console.ReadLine()); for (int i = x; i < y; i++) { if (IsPrime(i)) Console.Write("{0}, ", i); } Console.ReadKey(); } } }