Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int func(const int n) {
- if (n <= 1) {
- return 1;
- } else {
- return n * func(n - 1);
- }
- }
- /*
- * func(3) = 3 * func(3 - 1)
- * |
- * |___ func(2) = 2 * func(2 - 1)
- * |
- * |__ func(1) = 1
- *
- * func(3) = 3 * 2 * 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement