| Example MYFACT.PRT |
; MYFACT
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Ignore input and print out factorial of numbers from Start to End.
; Demonstrate the usage of recursive UDFs.
FUNCTION MyFact(n)
IF LT(n, 1)
; This RETURN does not end definition, because inside IF
RETURN 1
FI
; This RETURN end definition
RETURN MUL(n, MyFact(DEC(n)))
; Here main code begins
Start = 0
End = 20
FOR J = Start TO End
CONSOLELN "Factorial of " PFORMAT("2d", J) " is: " MyFact(J)
NEXT
ABORT 0
| Samples index | Next example | Previous example | Contents | Index |