Scheme: factorial function


Implementation of factorial function in Scheme language.

It is based on the formula:
n! = n * (n - 1)!
and
0! = 1


This first implementation in a recursive way:
(define (factorial x)
  (if (= x 0)
	  1
	  (* x (factorial (- x 1)))))


This second implementation in a iterative way:
(define (factorial x)
  (define (fact-iter a product)
	(if (= a 0)
		product
		(fact-iter (- a 1) (* product a))))
  (fact-iter x 1))