Last active
December 10, 2016 12:47
-
-
Save IsuraManchanayake/fb5aab8e4f26e5c3fac51cd002455b29 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_coprime_2(int64_t) | |
L = 100000000 : R = 100100000 | |
test 1 duration : 0.418 s | |
test 2 duration : 0.393 s | |
test 3 duration : 0.397 s | |
test 4 duration : 0.406 s | |
test 5 duration : 0.379 s | |
test 6 duration : 0.381 s | |
test 7 duration : 0.383 s | |
test 8 duration : 0.383 s | |
test 9 duration : 0.376 s | |
test 10 duration : 0.38 s | |
average of 10 test(s) : 0.3896 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_coprime_2(int64_t a) { | |
if(a % 2 == 0) return a == 2; | |
double lim = sqrt(a); | |
for(int i = 3; i <= lim; i += 2) | |
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