src/alfred/math/utils.hpp
Required by
Code
#ifndef AFMT_UTIL
#define AFMT_UTIL
constexpr bool is_prime(long long x) {
if (x < 2) return false;
for (long long i = 2; i * i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
template <class T>
inline T gcd(T a, T b) {
return b == 0 ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
return a / gcd(a, b) * b;
}
#endif
#line 1 "src/alfred/math/utils.hpp"
constexpr bool is_prime(long long x) {
if (x < 2) return false;
for (long long i = 2; i * i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
template <class T>
inline T gcd(T a, T b) {
return b == 0 ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
return a / gcd(a, b) * b;
}
Back to top page