Advertisement
Guest User

Untitled

a guest
Mar 13th, 2020
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. int func(const int n) {
  2.     if (n <= 1) {
  3.         return 1;
  4.     } else {
  5.         return n * func(n - 1);
  6.     }
  7. }
  8.  
  9. /*
  10.  * func(3) = 3 * func(3 - 1)
  11.  *                 |
  12.  *                 |___ func(2) = 2 * func(2 - 1)
  13.  *                                      |
  14.  *                                      |__ func(1) = 1
  15.  *
  16.  * func(3) = 3 * 2 * 1
  17.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement