For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2006 > Re: free implementation? factorial?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: free implementation? factorial?
Nicolas Neuss

2006-01-10, 9:55 pm

"Chuck Stevens" <charles.stevens@unisys.com> writes:

> Hmmm. I don't have any problem with the following program using either of
> the COBOL compilers supported for the Unisys MCP systems ('74 and '85
> standards respectively):
>
> IDENTIFICATION DIVISION.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 77 FACT-RES PIC 9(8).
> 77 ARGUMENT PIC 9(8).
> PROCEDURE DIVISION.
> MAIN-LINE.
> MOVE 1 TO FACT-RES. MOVE 5 TO ARGUMENT.
> PERFORM COMPUTE-FACTORIAL.
> DISPLAY FACT-RES.
> STOP RUN.
> COMPUTE-FACTORIAL.
> IF ARGUMENT > 1
> COMPUTE FACT-RES = FACT-RES * ARGUMENT
> SUBTRACT 1 FROM ARGUMENT
> PERFORM COMPUTE-FACTORIAL.


OK, this works for me (OpenCobol) after indenting by 8 and introducing a
line 2
PROGRAM-ID. FACTORIAL.

Thanks, Nicolas.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com