Here is a better explanation of the question I posted earlier.

My assignment is as follows:

The Integer 36 has an interesting property. It is a perfect

square(6^2) and is the sum of the integers from 1 to 8.

Develop a program using FUNCTIONS that determine all the numbers

between 1 and 500 that have this property. Write the number

along with the addends in a report form to the file program4.out.

Here is what I have come up with so far, this code is under

major construction so there are probably many areas that make

little or no sense, or contain sysntax errors. I am just posting

the code so you can get an idea of where I am headed with this.

Thanks in advance for taking the time to help!

PROGRAM Perfect_Numbers;

Type

RealArray = array[1..Int] of Real; {Array used to add consecutive

integers}

Var

X : RealArray;

Squares : Text; {Text file for storing squares from 1 to 500}

InFile : Text; {File used to read in squares}

Perfect_Numbers : Text; {Text file used to store final results}

Num : Integer; {Counter Variable}

{=== This program will find all perfect numbers up to 500

======================}

{=== Functions

=================================================================}

Function Find_squares(N : Integer) : Integer;

Begin

Find_Squares:=Sqr(N);

End; {Find_Squares}

{=== End Functions

=============================================================}

{=== Procedures

================================================================}

Procedure Find_Perfect_Squares; {Finds all squares that have consecutive

integers}

Begin {that add up to it.}

Assign(Perfect_Numbers, 'c:\bp\homework\Program4.out');

Rewrite(Perfect_Numbers);

Assign(InFile, 'c:\bp\homework\Data.out');

Reset(InFile);

While NOT (EOF(InFile)) DO

Begin

WriteLn(Perfect_Numbers, {Line1});

End;

Close(Perfect_Numbers);

Close(InFile);

{----This block of code will eventually be a nested procedure-------}

{----that adds the consecutive integers-----------------------------}

Procedure AddIntegers(Num : Integer);

Sum:=0;

FOR i:=1 TO MaxNum DO

WHILE Total <= Num DO

Begin

Total:=Sum + X[i]

End

IF Total = Num THEN

{-------------------------------------------------------------------}

{=== End Procedures

============================================================}

{=== Main Program

==============================================================}

BEGIN

Assign(Squares, 'c:\bp\homework\data.out');

Rewrite(Squares);

FOR Num:=1 TO 22 DO

Begin

WriteLn(Squares, Find_Squares(Num));

Find_Perfect_Squares;

End;

Close(Squares);

END.