Minilisp.pm/t/recursion.t

12 lines
206 B
Perl
Raw Normal View History

2021-04-09 00:01:27 +02:00
(plan 2)
2021-04-02 16:20:07 +02:00
;; Factorial
(defun factorial (n)
(if (> n 1)
(* n (factorial (- n 1)))
1))
(expect "Factorial of 5 is 120" (= (factorial 5) 120))
(expect "Factorial of 1 is 1" (= (factorial 1) 1))