14,335,077 members
Rate this:
See more: (untagged)
`<pre lang="c#">`
```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace p2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the number in which you want ot find the prime no");
bool isPrime = true;

for (int i = 1; i <= a; i++)
{
for (int j = 2; j <= a; j++)
{

if (i != j && i % j == 0)
{
isPrime = false;

break;
}

}

if (isPrime)
{
Console.WriteLine("Prime:" + i);
}

isPrime = true;
}

}
}
}```

Please check the code is right or not?
Posted
Updated 29-Sep-16 8:41am
v2

Rate this:

## Solution 1

Yes it right. and it is working properly in C# command prompt.
Rate this:

## Solution 2

Hello

```using System;

using System.Collections.Generic;

using System.Text;

namespace SoftwareAndFinance

{

class Math

{

{

bool bPrime = true;

int factor = num / 2;

int i = 0;

for (i = 2; i <= factor; i++)

{

if ((num % i) == 0)

bPrime = false;

}

return bPrime;

}

static void Main(string[] args)

{

Console.WriteLine("List of prime numbers between 0 - 1000");

for (int i = 0; i < 1000; i++)

{

Console.Write("{0,8:n}\t", i);

}

Console.WriteLine();

}

}

}```

Happy Coding