How to find prime number between 1 to n


class Program
{
static void Main(string[] args)
{
//int n = 100000;
int n = 0;
Console.WriteLine(“Type an integer number to get prime number between 1 to n”);
Int32.TryParse(Console.ReadLine(), out n);
PrintPrimes(n);
}

public static void PrintPrimes(int n)
{
bool isPrime = false;
for (int i = 2; i < n; i++) { isPrime = true; for (int j = 2; j <= Math.Sqrt(i); j++) { if (i % j == 0) { isPrime = false; break; } } if (isPrime) Console.Write(i + ” “); } Console.ReadKey(); } } [/csharp] [wpdm_file id=51]