Skip to content
Snippets Groups Projects
Commit c795373a authored by nimrod's avatar nimrod
Browse files

Added special cases for Python3, Python, PyPy and LuaJIT.

parent 437ffd2f
No related branches found
No related tags found
No related merge requests found
...@@ -18,8 +18,11 @@ clean: ...@@ -18,8 +18,11 @@ clean:
test: all test: all
@ time -f "%C : %E seconds" ./a.out $(ROUNDS) > /dev/null @ time -f "%C : %E seconds" ./a.out $(ROUNDS) > /dev/null
@ [ -n "$$(which python3)" ] && time -f "%C : %E seconds" ./prime.py $(ROUNDS) > /dev/null @ [ -n "$$(which python)" ] && time -f "%C : %E seconds" ./prime.py $(ROUNDS) > /dev/null
@ [ -n "$$(which python3)" ] && time -f "%C : %E seconds" python3 prime.py $(ROUNDS) > /dev/null
@ [ -n "$$(which pypy)" ] && time -f "%C : %E seconds" pypy prime.py $(ROUNDS) > /dev/null
@ [ -n "$$(which lua)" ] && time -f "%C : %E seconds" ./prime.lua $(ROUNDS) > /dev/null @ [ -n "$$(which lua)" ] && time -f "%C : %E seconds" ./prime.lua $(ROUNDS) > /dev/null
@ [ -n "$$(which luajit)" ] && time -f "%C : %E seconds" luajit prime.lua $(ROUNDS) > /dev/null
@ [ -n "$$(which php)" ] && time -f "%C : %E seconds" ./prime.php $(ROUNDS) > /dev/null @ [ -n "$$(which php)" ] && time -f "%C : %E seconds" ./prime.php $(ROUNDS) > /dev/null
@ [ -n "$$(which php7.0)" ] && time -f "%C : %E seconds" php7.0 prime.php $(ROUNDS) > /dev/null @ [ -n "$$(which php7.0)" ] && time -f "%C : %E seconds" php7.0 prime.php $(ROUNDS) > /dev/null
@ [ -n "$$(which ruby)" ] && time -f "%C : %E seconds" ./prime.rb $(ROUNDS) > /dev/null @ [ -n "$$(which ruby)" ] && time -f "%C : %E seconds" ./prime.rb $(ROUNDS) > /dev/null
......
#!/usr/bin/env python3 #!/usr/bin/env python
from __future__ import (absolute_import, division,
print_function, unicode_literals)
def is_prime(x): def is_prime(x):
from math import sqrt, ceil from math import sqrt, ceil
if sqrt(x).is_integer(): if sqrt(x).is_integer():
return False return False
for i in range(2, ceil(sqrt(x))): for i in range(2, int(ceil(sqrt(x)))):
if x % i == 0: if x % i == 0:
return False return False
return True return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment