Last active
December 10, 2016 12:21
-
-
Save IsuraManchanayake/e5d845139be4f3bc23a7194c344fa0b0 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_naive(int64_t) | |
L = 100000 : R = 200000 | |
test 1 duration : 19.897 s | |
test 2 duration : 20.491 s | |
average of 2 test(s) : 20.198 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
bool primality_naive(int64_t a) { | |
int c = 0; | |
for(int i = 1; i <= a; i++) | |
if(a % i == 0) { | |
c++; | |
if(c > 2) | |
return false; | |
} | |
if(c == 2) | |
return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment