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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
Archived Comments
1. Thanks for the above code. I am not sure whether t
View Tutorial By: Koolkabin at 2010-08-20 01:11:27
2. hello everyone... I am getting the error "sms
View Tutorial By: umar at 2010-12-19 04:20:33
3. Great Job
View Tutorial By: Niteen Dhule at 2015-02-09 06:37:03
4. sr. habla espanol necesito su ayuda... alguno tien
View Tutorial By: ROGER HERNANDEZ at 2011-09-13 15:20:01
5. very thanks... It's very useful to me...
Th
View Tutorial By: swathi. M at 2015-01-02 16:32:19
6. Actually, 120º *is* 2.0943951023931953
View Tutorial By: Stephen Blythe at 2012-04-02 03:39:03
7. nice material
View Tutorial By: ravi at 2008-12-24 00:40:12
8. thank you sir
View Tutorial By: ramya at 2010-01-11 00:42:05
9. Good one.........!!!
View Tutorial By: Shailesh Nakade at 2012-07-11 09:48:33
10. Hi all
I am using getAttribute but
View Tutorial By: Suvarna at 2012-01-12 06:56:55