A recursive procedure or function is one that calls itself. Why would you need it? Sometimes you need the result of the previous calculation in order to be able to calculate the current one. Take for example a very classical example: N!. Here all numbers from 1 to N are multiplied. This could be done using a for-loop and multiplying the current index with the previous multiplicant or this could be done recursively, where 1! is calculated then using this 2! is calculated.. N! is calculated using (N-1)! In orfer for this to be possible, we have to define recursive functions calling themselves.

Let's implement the factorial function:
 
function Factor(N:integer):integer;
begin
if N=0 then 
Factor:=1
else 
Factor:=Factor(N-1)*N;
end;

Important notes:

 
A First Look A First Look at Pascal Basic Input/Output Identifiers & Types
Constants Standard Functions If..Then Statement Case Statement
Repetitions Procedures and Functions Enumerated /Subrange Types Sets
I/O, Text Files Arrays Records Recursion
Pointer How to Debug Previous Exam Questions Advanced
ASCII Code Table Homepage University Homepage Computer Engineering Dept.