Advertisement
frasl

Untitled

Feb 15th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. template <int n> struct factorial {
  2.     enum {
  3.         value = n * factorial<n - 1>::value
  4.     };
  5. };
  6.  
  7. template <> struct factorial <1> {
  8.     enum {
  9.         value = 1
  10.     };
  11. };
  12.  
  13.  
  14. int main() {
  15.  
  16.     printf("%d\n", factorial<8>::value);
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement