Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (22 sloc) 654 Bytes
data division.
working-storage section.
01 n.
procedure division.
display "<h1>Factorial</h1>".
display "<p>Page generated by CobolScript</p>".
display "<table>".
display "<tr><th align='right'>n</th><th align='right'>n!</th></tr>".
perform show-factorial varying n from 1 to 10.
display "</table>".
stop run.
show-factorial section.
local result.
perform factorial using n giving result.
display "<tr><td align='right'>" n "</td><td align='right'>" result "</td></tr>".
factorial section using n.
local m.
if n = 1 then return n.
subtract 1 from n giving m.
perform factorial using m giving m.
multiply n by m.
return m.
Something went wrong with that request. Please try again.