Skip to content

Commit 91c77a9

Browse files
committed
Changed is_prime into a template method.
1 parent 5889261 commit 91c77a9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/alfred/math/utils.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
// O(sqrt(x)) to judge if x is a prime.
99
// It will be re-written in Miller-rabin sometime.
10-
constexpr bool is_prime(long long x) {
10+
template <class T>
11+
constexpr bool is_prime(T x) {
1112
if (x < 2) return false;
12-
for (long long i = 2; i * i <= x; i++) {
13+
for (T i = 2; i * i <= x; i++) {
1314
if (x % i == 0) return false;
1415
}
1516
return true;

0 commit comments

Comments
 (0)