Skip to content

Instantly share code, notes, and snippets.

@DJmong
Created March 23, 2022 04:16
Show Gist options
  • Select an option

  • Save DJmong/98edffbdcc63a252c4d1a16d990abd8c to your computer and use it in GitHub Desktop.

Select an option

Save DJmong/98edffbdcc63a252c4d1a16d990abd8c to your computer and use it in GitHub Desktop.
#include <iostream>
bool isPrime(const int &num)
{
if(num < 2) return false;
for(int i = 2; i*i <= num; ++i)
{
if(num % i == 0) return false;
}
return true;
}
int main(int argc, char **argv)
{
for(int i = 0; i < 100; ++i)
{
if(isPrime(i))
{
std::cout << i << std::endl;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment