Loading Makefile +4 −1 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ clean: test: all @ 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 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 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 Loading prime.py +6 −2 Original line number Diff line number Diff line #!/usr/bin/env python3 #!/usr/bin/env python from __future__ import (absolute_import, division, print_function, unicode_literals) def is_prime(x): from math import sqrt, ceil if sqrt(x).is_integer(): return False for i in range(2, ceil(sqrt(x))): for i in range(2, int(ceil(sqrt(x)))): if x % i == 0: return False return True Loading Loading
Makefile +4 −1 Original line number Diff line number Diff line Loading @@ -18,8 +18,11 @@ clean: test: all @ 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 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 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 Loading
prime.py +6 −2 Original line number Diff line number Diff line #!/usr/bin/env python3 #!/usr/bin/env python from __future__ import (absolute_import, division, print_function, unicode_literals) def is_prime(x): from math import sqrt, ceil if sqrt(x).is_integer(): return False for i in range(2, ceil(sqrt(x))): for i in range(2, int(ceil(sqrt(x)))): if x % i == 0: return False return True Loading