fact (Factorial Operator, simple recursion)

Help Contents Examples fact (Factorial Operator, simple recursion)
DNA (3d) Fern (3d)

fact (Factorial Operator, simple recursion)

Example:   Factoriel operator
File name: Fact.eli
Modified:  May 17, 2000
Author:    Pavel Christov Boychev
Version:   5.0
E-mail:    pavel@elica.net

Copyright © 1999-2000 Elica Group

This example contains a definition of the factorial function (mathematical operator !), calculated with recursion.

to :x!
	if :x=0 [output 1]

	if :x=1
	[
		output 1
	]
	[
		output :x*(:x-1)!
	]
end

make "'!.onpriority' 49

print "'0! = ' 0!
print "'1! = ' 1!
print "'2! = ' 2!
print "'3! = ' 3!
print "'4! = ' 4!
print "'5! = ' 5!
print "'10! =' 10!
print "'100! =' 100!
print "'1000! =' 1000!

DNA (3d) Fern (3d)