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. Hi... very nice tute... Thanks..
I am worki

View Tutorial          By: anuj at 2013-03-15 06:12:46

2. Daniel Jonsson, you should be thankful to this art
View Tutorial          By: dole at 2011-11-12 06:44:42

3. How to do the following
Create a class With

View Tutorial          By: Anurag at 2014-01-03 10:14:45

4. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: amit doshi at 2009-04-06 02:00:28

5. how i can used inheritence ?
View Tutorial          By: samee at 2008-02-16 12:54:27

6. I am getting this exeception when trying to send m
View Tutorial          By: praveen at 2012-12-27 11:15:14

7. I need dumps for practice
View Tutorial          By: Sanket barge at 2011-06-17 10:05:16

8. THANX :)
View Tutorial          By: Saurabh at 2012-01-02 16:13:06

9. Your solution has really helped me and educated me
View Tutorial          By: Tziq at 2011-01-25 08:06:06

10. hi ,
i am a beginner in java. please tell m

View Tutorial          By: aun at 2011-11-18 06:47:56