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. Very useful tutorial. But if same code is executed
View Tutorial          By: Jitendra Kumar Mahto at 2011-08-12 15:10:14

2. Hello Mr. Developer of above proj....plz let me kn
View Tutorial          By: Prakash Vishwakarma at 2011-07-08 10:02:22

3. Float f=99.7f;
int i1=Integer.parseInt(f);<

View Tutorial          By: Ashwin at 2012-12-23 05:14:04

4. Very good tutorial, but I have a small question he
View Tutorial          By: Mohammad NABIL at 2010-07-20 05:58:19

5. Good one!!!!!!!!
View Tutorial          By: Manya at 2011-06-30 11:59:25

6. It works like a charm. Thanks a lot.
View Tutorial          By: Balram at 2008-08-22 21:18:44

7. I am using my NOKIA 2700 classic via blutooth conn
View Tutorial          By: Raheela at 2010-05-06 03:11:36

8. Dear admin,
your Recaptcha design is not go

View Tutorial          By: surendra kumar sharma at 2013-02-02 05:58:35

9. Microsoft VB.net 2008 not showing Crystal Report V
View Tutorial          By: Ali at 2011-11-30 03:21:00

10. package alphabets;

import java.util

View Tutorial          By: Nitish at 2013-01-25 04:06:38