diff options
Diffstat (limited to 'tests/exec/fact_loop.cpp')
-rw-r--r-- | tests/exec/fact_loop.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/exec/fact_loop.cpp b/tests/exec/fact_loop.cpp new file mode 100644 index 0000000..da13f82 --- /dev/null +++ b/tests/exec/fact_loop.cpp @@ -0,0 +1,11 @@ +#include <iostream> + +int fact_loop(int n) { + int r = 1; + while (n > 1) r = r * n--; + return r; +} + +int main() { + std::cout << fact_loop(5) << "\n"; +} |