Skip to content

Instantly share code, notes, and snippets.

@philopaterwaheed
Created January 31, 2024 08:58
Show Gist options
  • Save philopaterwaheed/fe0156377d7085de1a80937e723bb2b7 to your computer and use it in GitHub Desktop.
Save philopaterwaheed/fe0156377d7085de1a80937e723bb2b7 to your computer and use it in GitHub Desktop.
a function to determine if a number is prime or now
bool is_prime (int n )
{
if (n == 2 )
return true;
if ( n == 1 )
return false ;
for (int i =2 ; i * i < (n) ; i ++ )
if (n % i == 0 )
return false;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment