RosettaCodeData/Task/Compile-time-calculation/C++/compile-time-calculation-2.cpp

13 lines
189 B
C++
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
#include <stdio.h>
constexpr int factorial(int n) {
return n ? (n * factorial(n - 1)) : 1;
}
constexpr int f10 = factorial(10);
int main() {
printf("%d\n", f10);
return 0;
}