A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Factorial in COBOL page! Here, you'll find the source code for this program as well as a description of how the program works.
identification division.
program-id. factorial.
data division.
working-storage section.
01 cmd-args pic x(38).
01 num pic s9(7).
01 result pic z(18)9 value 1.
procedure division.
main.
accept cmd-args from command-line
if function test-numval(cmd-args) not = 0
perform show-usage
end-if
compute num = function numval(cmd-args)
if num < 0
perform show-usage
end-if
compute result = function factorial(num)
display result
stop run.
show-usage.
display "Usage: please input a non-negative integer"
stop run.
Factorial in COBOL was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.