A fixed-point arithmetic class wants to reduce its ratio at compile time — the denominators are template parameters, so the GCD must be one too. The Euclidean algorithm is two lines; the exercise is making the compiler run them.
Implement gcd_v<A, B> — the greatest common divisor as a compile-time constant. gcd_v<18, 12> == 6, checked by static_assert.
gcd(a, 0) is a; otherwise gcd(a, b) = gcd(b, a % b). That is the whole algorithm.
A constexpr helper function with a loop keeps the variable template a one-liner.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.