Jump to content

Sum of a series: Difference between revisions

Added Oberon-02
(add RPL)
(Added Oberon-02)
Line 2,024:
{{out}}
<pre>1.643934566681561</pre>
 
=={{header|Oberon-2}}==
{{trans|Modula-2}}
<syntaxhighlight lang="oberon2">MODULE SS;
 
IMPORT Out;
 
TYPE
RealFunc = PROCEDURE(r:REAL):REAL;
 
PROCEDURE SeriesSum(k,n:LONGINT;f:RealFunc):REAL;
VAR
total:REAL;
i:LONGINT;
BEGIN
total := 0.0;
FOR i := k TO n DO total := total + f(i) END;
RETURN total
END SeriesSum;
PROCEDURE OneOverKSquared(k:REAL):REAL;
BEGIN RETURN 1.0 / (k * k)
END OneOverKSquared;
BEGIN
Out.Real(SeriesSum(1,1000,OneOverKSquared),10);
Out.Ln;
END SS.
</syntaxhighlight>
 
{{out}}
<pre>1.64393E+00
</pre>
 
=={{header|Objeck}}==
40

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.