Jump to content

Sum of a series: Difference between revisions

→‎{{header|ALGOL 68}}: Corrected the range of the summation and formatted the output.
(Sum of a series en Yabasic)
(→‎{{header|ALGOL 68}}: Corrected the range of the summation and formatted the output.)
Line 125:
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Revision 1 - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d]}}
<lang algol68>MODE RANGE = STRUCT(INT lwb, upb);
 
Line 141 ⟶ 136:
 
test:(
RANGE range = (1,1001000);
PROC f = (INT x)LONG REAL: LENG REAL(1) / LENG REAL(x)**2;
print(("Sum of f(x) from ", whole(lwb OF range, 0), " to ",whole(upb OF range, 0)," is ", fixed(SHORTEN sum(f,range),-8,5),".", new line))
)</lang>
Output:
<pre>
Sum of f(x) from +1 to 1000 is +100 is +1.63498390018489e +064393.
</pre>
 
3,045

edits

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