Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2011 19:49
Show Gist options
  • Select an option

  • Save anonymous/1507400 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/1507400 to your computer and use it in GitHub Desktop.
prime
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