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. i run above code in my netbean ide, i din't get ou
View Tutorial          By: manish sharma at 2013-04-03 05:28:40

2. Showing code with quote tags is pretty rubbish. :/
View Tutorial          By: Daniel Jonsson at 2011-09-01 14:01:04

3. I want to creat a bilingual dictionary for mobile
View Tutorial          By: Maryam at 2011-01-25 02:28:44

4. how do one off the alarm after it has triggered th
View Tutorial          By: Asika at 2009-10-01 07:28:50

5. can any body help me ??????????
i `he get a

View Tutorial          By: gkggt at 2013-02-11 12:09:04

6. Thanks!
View Tutorial          By: misterTi at 2015-03-18 17:48:41

7. HI Friends,

I am new to java and i

View Tutorial          By: Srini at 2015-04-05 17:00:58

8. now I know what isset is for, thank you very much
View Tutorial          By: Anonymous at 2010-12-23 20:43:29

9. i want to learn the java from basics onwards.
View Tutorial          By: vinay at 2010-03-08 22:54:15

10. me too got the same problem....
but m sure

View Tutorial          By: HEHE at 2008-11-19 01:49:04