Prime Numbers
// Prime Numbers
Console.WriteLine("Enter a number to check wheater is it Prime number or not");
int a = int.Parse(Console.ReadLine());
int i = 2;
while (i <= a - 1)
{
if (a % i == 0)
{
Console.WriteLine("It's a not a Prime number");
break;
}
i++;
if (a == i)
{
Console.WriteLine("It's Prime number");
}
}
Console.ReadLine();
No comments:
Post a Comment