Created
November 24, 2017 15:50
-
-
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
This file contains 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
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