Comment on Tutorial - Checking Prime Number in C++ By Grant Braught



Comment Added by : Anonymous

Comment Added at : 2013-02-27 05:38:27

Comment on Tutorial : Checking Prime Number in C++ By Grant Braught
This program is mush faster and finer than given program.



#include <iostream>
#include <math.h>

bool IsPrime(int number)
{
for (int i=2; i<sqrt(number/2); i++)
{
if (number % i == 0)
{
return false;
}
}

return true;
}
int main()
{
int number;

cout << \"Enter an integer: \";
cin >> number;

if (IsPrime(number))
cout << number << \" is prime.\" << endl;
else
cout << number << \" is not prime.\" << endl;

return 0;
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Nice article..
View Tutorial          By: senthil at 2009-09-09 00:22:40

2. How do you remove an element from the map?
View Tutorial          By: Shreejit at 2012-01-29 16:53:27

3. i installed the code in ecllipse,but i have one do
View Tutorial          By: vamsi at 2015-05-19 10:56:25

4. Good example for vector
View Tutorial          By: mangai at 2011-07-07 09:46:10

5. Please provide some more examples ...It will be ve
View Tutorial          By: it interview questions at 2012-09-29 05:07:55

6. Thanks a lot! simple and clear explanation! Great!
View Tutorial          By: Fabio Henrique at 2010-03-29 15:23:56

7. How can I save the canvas edited by the user from
View Tutorial          By: pavan at 2014-10-14 08:26:55

8. Clear explanation...
View Tutorial          By: Nisha at 2013-01-31 05:10:29

9. Hi All,

I am new to J2ME Applicatio

View Tutorial          By: golemnagesh at 2010-12-05 22:43:50

10. You should consider using different threads that a
View Tutorial          By: Jeremy at 2010-01-13 23:02:11