diff options
Create fact.cpp
1 files changed, 16 insertions, 0 deletions
| -rw-r--r-- | Sem. 12/fact.cpp | 16 |
diff --git a/Sem. 12/fact.cpp b/Sem. 12/fact.cpp new file mode 100644 index 0000000..bd97a5e --- /dev/null +++ b/Sem. 12/fact.cpp @@ -0,0 +1,16 @@ +#include <iostream> + + + +unsigned factRec(unsigned n) // О(n) +{ + if (n == 0) + return 1; + return n * factRec(n - 1); +} + +int main() +{ + std::cout << factRec(5); + +} |
