$c+
module test14_1 { factorial
 test of recursive procedures with no locals or parameters in  gcl }
private
 integer inArg, { input argument}
	 result,    { return result}
	 oldArg;    { local to nFac}
	 
 typedefinition tuple [procedure nFac()] factorial;
 
 factorial fac;
 
 procedure factorial@nFac
 	begin
	   if 	inArg = 0 -> result := 1;
	   [] 	inArg > 0 -> 
	   	inArg, oldArg := inArg - 1, inArg;
	   	fac!nFac(); { recurse }
	   	oldArg, result, inArg := oldArg +1, oldArg*result, oldArg;
	   fi;
	end;
	
begin 
	oldArg := 0;
	read inArg ;
	fac!nFac();
	write inArg,' factorial is ', result;
end.
