Skip to content

Instantly share code, notes, and snippets.

@kjk
Last active May 31, 2020 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjk/f5300f79d9c581e1a4ae2e727061e50d to your computer and use it in GitHub Desktop.
Save kjk/f5300f79d9c581e1a4ae2e727061e50d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <type_traits>
template<long long n>
struct factorial :
std::integral_constant<long long, n * factorial<n - 1>::value> {};
template<>
struct factorial<0> :
std::integral_constant<long long, 1> {};
int main()
{
std::cout << factorial<7>::value << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment