Skip to content

Instantly share code, notes, and snippets.

@DCCoder90
Created November 24, 2017 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DCCoder90/6cc30acd7c8860c37b2fe6fd862c4885 to your computer and use it in GitHub Desktop.
Save DCCoder90/6cc30acd7c8860c37b2fe6fd862c4885 to your computer and use it in GitHub Desktop.
Quick and dirty litter method to determine if a number is prime. Still has some issues that need to be worked out for int vs ulong
public static bool CalcIsPrime(dynamic number,out dynamic failure)
{
failure = 0;
if (number == 1) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;
for (dynamic i = 2; i < (number/2); i++)
{
if (number % i == 0){
failure = i;
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment