13,406,787 members (53,591 online)
See more:
how do i print prime and not prime number from 300 to 400 by using for loop and if statement.
Posted 12-Feb-13 17:48pm

## Solution 1

You take a paper, a pen and you write : 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397
:-)

more seriously here is a function to check if a number is a prime or not but beware you can only use it with relatively small numbers as it is not particularly optimized...

```public static bool IsPrime(this int number)
{
return (Enumerable.Range(1,number).Where(x => number % x == 0).Count() == 2);
}```

## Solution 2

Hello, this is logic to find out prime numbers between 300 to 400.

```namespace prime_number_series
{
class Program
{
static void Main(string[] args)
{
for (int i = 300; i <= 400; i++)
{
int count1 = 0;
int count2 = 0;
for (int k = 301; k < i - 1; k++)
{
int rem = i%k;
if (rem == 0)
{
count1++;
}
else
{
count2++;
}
}
if (count1 == 0)
{
Console.Write("{0} \t",i);
}

}

}
}

}```

Top Experts
Last 24hrsThis month
 phil.o 280 RickZeeland 174 F-ES Sitecore 165 ppolymorphe 158 CPallini 140
 OriginalGriff 5,765 Maciej Los 3,315 Richard MacCutchan 2,031 CPallini 1,940 F-ES Sitecore 1,385