Skip to content

Commit 561047f

Browse files
committed
feat: Add constexpr template function for compile-time prime checking
1 parent f0e337e commit 561047f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

weilycoder/number-theory/prime.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ constexpr bool is_prime(uint64_t n) {
100100
return miller_rabin32(static_cast<uint32_t>(n));
101101
return miller_rabin64(n);
102102
}
103+
104+
/**
105+
* @brief Compile-time primality test for a given integer.
106+
* @tparam x The integer to test for primality.
107+
* @return true if x is prime, false otherwise.
108+
*/
109+
template <uint64_t x> constexpr bool is_prime() { return is_prime(x); }
103110
} // namespace weilycoder
104111

105112
#endif

0 commit comments

Comments
 (0)