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. thank you
i memorized it easly .

View Tutorial          By: kibrom at 2011-04-27 11:46:24

2. i want to know about simple java structure with br
View Tutorial          By: Rambahaz at 2009-09-07 06:41:25

3. i want to know how to connect one page to another
View Tutorial          By: mahesh at 2009-08-26 01:31:40

4. simple examples that i can understand ,.,,by the w
View Tutorial          By: Chriskuang at 2015-03-19 03:05:59

5. thanks you're such an angel :) thanks for solving
View Tutorial          By: Tanzeela Ali at 2013-04-01 07:42:08

6. Hi santhosh,
Try it ou

View Tutorial          By: Kiran at 2011-12-14 04:31:29

7. So, is it possible to use the getClass() and getRe
View Tutorial          By: cee at 2014-11-29 14:27:10

8. It doesnt works in Mozilla Firefox.


View Tutorial          By: K Vijay Anand at 2010-06-20 09:11:26

9. your code error

because i try to ru

View Tutorial          By: Nasser at 2013-01-09 10:33:34

10. hi
this is helpful, but file store it in m

View Tutorial          By: Mahesh at 2011-11-10 06:52:39