From: William M. Klein on
Are you looking for something like

Compute Output-field = Function Factorial (input-field)

???

See (for one implementation of ANSI/ISO conforming - since '89 - FACTORIAL
function),

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR30/7.1.22


--
Bill Klein
wmklein <at> ix.netcom.com
"Nicolas Neuss" <firstname.lastname(a)iwr.uni-heidelberg.de> wrote in message
news:87mzi5tn9y.fsf(a)ortler.iwr.uni-heidelberg.de...
> Hello,
>
> I am teaching a CS course ("Programming and Software Techniques") at the
> university of Heidelberg. This course uses C++, but I want to give my
> students also a feeling for other languages. To this end, I have reserved
> a little bit of time (5-10 minutes of each session) for telling them a
> little about other languages (history, some important features) and showing
> them the factorial function written in this language.
>
> Now, since COBOL is an important language, I want to include it in this
> way, too. I was able to find some information about COBOL in Wikipedia
> which should suffice for the short overview, but I have not succeeded in
> finding a free implementation for COBOL. Is there such a thing (maybe a
> demo version)? Furthermore, as much as I understand the factorial function
> is already available in modern COBOL implementations, so it is difficult to
> find a suitable program (at least, what I found with Google is either
> untested or looks suboptimal). If factorial would not be available, how
> would it look like in modern COBOL?
>
> Thanks, Nicolas.


From: charles hottel on

"Nicolas Neuss" <firstname.lastname(a)iwr.uni-heidelberg.de> wrote in message
news:87lkxpgnwc.fsf(a)ortler.iwr.uni-heidelberg.de...

<snip>

> I had found this one already, but had somehow hoped that a nicer version
> would be possible, e.g. something like in
>
> <http://groups.google.com/group/comp.lang.cobol/msg/fae713b0615c1445>
>
> Thank you,
>
> Nicolas.

I do not think that the program at this link is valid COBOL. A COBOL
program can be recursive but COBOL paragraphs are not recursive at least not
in the compilers that I am familiar with.


From: Richard on
> but I have not succeeded in
> finding a free implementation for COBOL.

http://www.adtools.com/student/index.htm

http://www.opencobol.org/

http://tiny-cobol.sourceforge.net/

http://www.thekompany.com/products/kobol/demo.php3?PHPSESSID=5ba92a9208b660be52e1baa9669df9af

From: Nicolas Neuss on
Louis Krupp <lkrupp(a)pssw.nospam.com.invalid> writes:

> I've never used TinyCobol, but it might be worth a try. I think an
> iterative factorial implementation might be easier to follow than a
> recursive routine. This would look something like:
>
> move 1 to factorial.
> perform varying t from 2 to number
> multiply factorial by t
> end-perform.
>
> Louis

Thanks, I'll try this, too.

Nicolas.
From: Karl Kiesel on

"Louis Krupp" <lkrupp(a)pssw.nospam.com.invalid> schrieb im Newsbeitrag
news:11s5hqph3vd97e6(a)corp.supernews.com...
>... This would look something like:
>
> move 1 to factorial.
> perform varying t from 2 to number
> multiply factorial by t
> end-perform.
>
> Louis

sorry, but the result of this multiplication will be stored in t; either a
giving phrase should be added or the operands exchanged! Also the syntax of
the conditions is not standardconforming; therefore the code should read:

...
perform varying t from 2 until t > number
multiply t by factorial
end-perform

K. Kiesel


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: Data Representation in COBOL
Next: xml acucobol