IsPrime
namespace UET
{
class Program
{
//Entry point
static void Main()
{
Start:
Console.WriteLine("Enter a number");
int number = int.Parse(Console.ReadLine());
bool answer = IsPrime(number);
Console.WriteLine(answer);
goto Start;
}
//methods
static bool IsPrime(int num)
{
if (num == 1 || num == 2 || num == 3)
{
return true;
}
else if (num % 2 == 0 || num % 3 == 0)
{
return false;
}
else
{
return true;
}
}
}
}
Comments
Post a Comment