Last active
May 30, 2018 18:50
-
-
Save marcuskaufmann/52f48c9d72bd5eb5d4af2418baa60cdc to your computer and use it in GitHub Desktop.
Ranged prime check functions
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
Every function below outputs 1 if x is prime and 0 if it is not prime, but only guranteed (tested) for the given range. | |
The obvious presence of very small prime numbers in these functions is remarkable. | |
x - Range | function | |
0- 99 | y = mod(min(x*mod(x*mod(x, 5)*mod(x, -3), 7) - 5*mod(x*mod(x, 5)*mod(x, -3), 7), x - 8), 2) | |
100-199 | y = min(mod(x*mod(x*mod(x*mod(-x, -3), 5), -11), 7), mod(x, 2)) | |
200-299 | y = min(mod(x*mod(x*mod(x^2*mod(x, 5)*mod(x, -3), -19), 7), 13), mod(x, 2)) | |
300-399 | y = min(mod(x*mod(2*x*mod(mod(x, -13)*mod(x*mod(x, -3), 5), x), 22), 7), mod(x, 2)) | |
400-499 | y = min(mod(x*mod(mod(x^2, -3)*mod(-2*x*mod(x, 5), 22), x), 7), mod(x, 2)) | |
500-599 | y = min(mod(x*mod(r*x^3*mod(x*mod(x, -3), 5), 22), 7), mod(x, 2)) | |
600-699 | y = min(mod(mod(x*mod(x, -3)*mod(x*mod(2*x*mod(2*x^2, 5), 645), 22), 7), 5), mod(x, 2)) | |
700-799 | y = min(mod(x*mod(mod(mod(x, -9)*mod(-3*x*mod(x, 5)*mod(x, -3), -19), 7), -19), 7), mod(x, 2)) | |
800-899 | y = min(mod(x*mod(5*x*mod(mod(-(x*mod(x, -3)*mod(7*x, 5)), -19), -3), -11), 7), mod(x, 2)) | |
900-999 | y = and(mod(x*r*mod(x*mod(x, -3)*mod(x*r - x^2, 5), -13), 7), mod(x, 2)) | |
1000-1099 | y = min(mod(mod(mod(mod(-25*x, -19), 7)*mod(x*mod(x, -3)*mod(1068*x, -20), 7), 28), 5), mod(x, 2)) | |
10000-10099 | y = round(min(mod(x*mod(x*mod(x*mod(ceil(9.8547213163749*mod(x, 5)*mod(x*mod(min(10074, x), 5), -3)), -19), 8), 7), 9.8547213163749), mod(x, 2))) | |
100000-100099 | y = min(mod(min(x, 100072), 2), mod(c*mod(c, -9)*mod(mod(-(x*mod(x, 5)*mod(x, -3)), -19), -3), 5)) | |
y = floor(mod(x, 2)*max(mod(x, 1.04431235561689), 38.0067420293481*mod(x, 0.343792485691626)*mod(x, 0.119788465831166))) | |
r = round(sqrt(2*x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment