I needed a method to check whether given number is prime or not. I searched on internet and I found different functions but they were complex. So, I designed my own method for checking whether the number is prime or not. It is working for me. I just wanna know if it is correct or not. The code is given below:
bool IsPrime(int n)
{
for (int i = 2; i <= 7; i++)
{
if (i < n && n % i == 0)
{
return false;
}
if (i == n)
{
return true;
}
}
return true;
}