toolbox/gcd/src/gcd.hpp
2025-03-30 13:48:18 +02:00

11 lines
297 B
C++

#include <stdint.h>
/**
* @brief Calculate the greatest common divisor (GCD)
*
* @param a First integer
* @param b Second integer
* @return greatest common divisor between a and b
*/
constexpr uint64_t gcd(const uint64_t a, const uint64_t b) noexcept { return a == 0 ? b : gcd(b % a, a); }