
(* some arithmetic examples, 19 March 1989. *)

CLOUT("Computing 50! ...").

PROCEDURE fac(n);
VAR   d, i: ANY;
BEGIN d:=1; i:=1;
      WHILE i < n DO
            i:=i+1;
            d:=IPROD(d,i)
            END;
      RETURN(d)
      END fac;

x:=fac(50).

IWRITE(x).

CLOUT("Factorizing 50! ...").

y:=IFACT(x).

CLOUT("Computing 50 digits of pi ...").

APSPRE(50).

x:=APPI().

APWRIT(x).

CLOUT("Computing 50 digits of e ...").

PROCEDURE compE(n);
(* sum 1/(i!) *)
VAR   s, x, d, i, y: ANY;
BEGIN x:=RNINT(1); d:=1; s:=x; i:=0;
      WHILE i < n DO
            i:=i+1;
            d:=IPROD(d,i);
            y:=RNINT(d);
            y:=RNQ(x,y);
            s:=RNSUM(s,y)
            END;
      (*RNDWR(y,2*n); BLINES(0); check precision *)
      RETURN(s)
      END compE;

e:=compE(43).

RNWRIT(e).

RNDWR(e,50).

CLOUT("... finished.").
