Advertisement
frasl

Untitled

Feb 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. // C++11 constexpr functions use recursion rather than iteration
  2. // (C++14 constexpr functions may use local variables and loops)
  3. constexpr int factorial(int n)
  4. {
  5.     return n <= 1 ? 1 : (n * factorial(n - 1));
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement