Success within U
Actions May not always bring happiness, But there is no happiness without Action...
Monday, October 20, 2008
Check Prime numbers
Function to Check Prime number
Here a simple function to check whether the given number is Prime or not.
private bool isPrime(int tmp)
{
if (tmp <= 3)
return true;
else
{
for (int cnt = 2; cnt < tmp; cnt++)
{
if (tmp % cnt == 0)
return false;
}
return true;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment