/* * $VER: Fakultät.rexx V1.1 (16.06.2000) * * Copyright 2000 by Christoph Kirsch * * Ein Beispiel für die Realisierung von Funktionen mit ARexx. * Berechnet die Fakultät (x!) einer gegebenen Zahl x. * Aufruf als Funktion mit: =AREXX("ARexx/Fakultät.rexx",x). * * An example for functions done with ARexx. * This script calculates the faculty (x!) of a given value. * Call like this: =AREXX("ARexx/Fakultät.rexx",x) * */ n = arg() if n > 0 then do args = arg(1) i = 1 p = POS('|',args) do while p ~= 0 argument.i = LEFT(args,p-1) args = RIGHT(args,LENGTH(args)-p) i = i+1 p = POS('|',args) end argument.i = args n = i end /* -------------------------------------------------*/ /* BEGIN OF YOUR CODE */ /* -------------------------------------------------*/ f = 1 do i=1 to argument.1 f = f * i end res = f /* -------------------------------------------------*/ /* END OF YOUR CODE */ /* -------------------------------------------------*/ OPEN(ret,"env:DATAM_II_RC",'WRITE') WRITELN(ret,res) CLOSE(ret)