Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

recursion factorial algorithm

FUNCTION FACTORIAL (N: INTEGER): INTEGER
(* RECURSIVE COMPUTATION OF N FACTORIAL *)

BEGIN
  (* TEST FOR STOPPING STATE *)
  IF N <= 0 THEN
    FACTORIAL := 1
  ELSE
    FACTORIAL := N * FACTORIAL(N - 1)
END; (* FACTORIAL *)
Source by planetmath.org #
 
PREVIOUS NEXT
Tagged: #recursion #factorial #algorithm
ADD COMMENT
Topic
Name
8+9 =