Created
December 21, 2011 19:49
-
-
Save anonymous/1507400 to your computer and use it in GitHub Desktop.
prime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool isPrime(int x) | |
| { | |
| for (int count = 2; count * count <= x; ++count) | |
| { | |
| if ((x % count) == 0) | |
| { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| void main() | |
| { | |
| int countprime = 0; | |
| int times = 1000; | |
| // start a stopwatch | |
| for (int count = 0; count < times; ++count) | |
| { | |
| if (isPrime(27644437)) | |
| { | |
| countprime++; | |
| } | |
| } | |
| // stop the stopwatch | |
| // report the total elapsed time, divided by "times" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment