Introduction | Language Structure | IB Statements | File System | Comet 32 Runtime | Index |
User Defined Procedures in Comet32 (Procs)
! Declare Subroutines And Functions
Numeric Factor(n)
length 32.0 & local i z
print (et)
fact:
print 'factorial of what?'
input i
if i > 29 print 'Warning -- factorial of a number > 29 will overflow' & wait
if i = 0 stop
Z = Factor(I) ! Call our function here
Print i;' Factorial Is ' ! Iterate through the function to get the factorial
Print z
Wait
z = Factorial(I) ! use the math library to get the factorial for validation purposes
Print z
wait
goto fact
end
Numeric Factor(n)
Length 32.0 & Local x
print 'fact';n
if n <= 1 Procreturn 1
print 'returning ';n &wait
x = n - 1
Procreturn Factor(x) * n ! Calling myself
End