Last active
December 10, 2016 12:27
-
-
Save IsuraManchanayake/5bc763fd564bb410977f68c64bd6b753 to your computer and use it in GitHub Desktop.
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
primality test using primality_sqrt_bound(int64_t) | |
L = 100000000 : R = 100100000 | |
test 1 duration : 0.761 s | |
test 2 duration : 0.762 s | |
test 3 duration : 0.764 s | |
test 4 duration : 0.771 s | |
test 5 duration : 0.741 s | |
test 6 duration : 0.741 s | |
test 7 duration : 0.769 s | |
test 8 duration : 0.744 s | |
test 9 duration : 0.737 s | |
test 10 duration : 0.741 s | |
average of 10 test(s) : 0.7531 s |
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
#include <cmath> | |
bool primality_sqrt_bound(int64_t a) { | |
double lim = sqrt(a); | |
for(int i = 2; i <= lim; i++) | |
if(a % i == 0) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment