Skip to content

Commit

Permalink
Create 6 kyu - Compile time #1 Factorial.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
freedan42x authored Jul 18, 2022
1 parent eb54f48 commit 0ea882b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cpp/6 kyu - Compile time #1 Factorial.cpp
Original file line number Diff line number Diff line change
@@ -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 <int x>
struct factorial {
static constexpr ull_t value = factorial_impl(x);
};

0 comments on commit 0ea882b

Please sign in to comment.