home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
ozogan
/
REKURZE.IPS
< prev
next >
Wrap
Text File
|
1997-08-17
|
656b
|
20 lines
FUNCTION factorial(n: real): real;
IF (n = 0) then
factorial := 1
ELSE
factorial := n*factorial(n-1);
ENDIF
ENDFUNC;
PROCEDURE main
ConsoleClear;
WRITELN('Test rekurze:');
WRITELN('faktorißl Φφsla 1 je:', factorial(1):5); { 1}
WRITELN('faktorißl Φφsla 2 je:', factorial(2):5); { 2}
WRITELN('faktorißl Φφsla 3 je:', factorial(3):5); { 6}
WRITELN('faktorißl Φφsla 4 je:', factorial(4):5); { 24}
WRITELN('faktorißl Φφsla 5 je:', factorial(5):5); { 120}
WRITELN('faktorißl Φφsla 6 je:', factorial(6):5); { 720}
WRITELN('faktorißl Φφsla 7 je:', factorial(7):5); {5040}
ENDPROC;