WPILibC++ 2023.4.3
lcm.hpp File Reference

Go to the source code of this file.

Namespaces

namespace  internal
 

Functions

template<typename T >
constexpr T internal::lcm_compute (const T a, const T b) noexcept
 
template<typename T1 , typename T2 , typename TC = common_t<T1,T2>>
constexpr TC internal::lcm_type_check (const T1 a, const T2 b) noexcept
 
template<typename T1 , typename T2 >
constexpr common_t< T1, T2 > lcm (const T1 a, const T2 b) noexcept
 Compile-time least common multiple (LCM) function. More...
 

Function Documentation

◆ lcm()

template<typename T1 , typename T2 >
constexpr common_t< T1, T2 > lcm ( const T1  a,
const T2  b 
)
constexprnoexcept

Compile-time least common multiple (LCM) function.

Parameters
aintegral-valued input.
bintegral-valued input.
Returns
the least common multiple between integers a and b using the representation

\[ \text{lcm}(a,b) = \dfrac{| a b |}{\text{gcd}(a,b)} \]

where \( \text{gcd}(a,b) \) denotes the greatest common divisor between \( a \) and \( b \).