Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.32 KB | None | 0 0
  1. # let rec fact = function 0 -> 1 | n -> n * fact (n - 1);;
  2. val fact : int -> int = <fun>
  3. # fact 5;;
  4. - : int = 120
  5. # #trace fact;;
  6. fact is now traced.
  7. # fact 5;;
  8. fact <-- 5
  9. fact <-- 4
  10. fact <-- 3
  11. fact <-- 2
  12. fact <-- 1
  13. fact <-- 0
  14. fact --> 1
  15. fact --> 1
  16. fact --> 2
  17. fact --> 6
  18. fact --> 24
  19. fact --> 120
  20. - : int = 120
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement