diff --git a/cpp/6 kyu - Compile time #1 Factorial.cpp b/cpp/6 kyu - Compile time #1 Factorial.cpp new file mode 100644 index 0000000..ef5d69b --- /dev/null +++ b/cpp/6 kyu - Compile time #1 Factorial.cpp @@ -0,0 +1,13 @@ +typedef unsigned long long ull_t; + +constexpr ull_t factorial_impl(int n) +{ + if (n <= 1) return 1; + + return n * factorial_impl(n - 1); +} + +template +struct factorial { + static constexpr ull_t value = factorial_impl(x); +};