Sum of a series: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: update works with |
Add Seed7 example |
||
Line 1,041:
(sum 1 1000 (lambda (x) (/ 1 (* x x)))) ; fraction
(exact->inexact (sum 1 1000 (lambda (x) (/ 1 (* x x))))) ; decimal</lang>
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
include "float.s7i";
const func float: invsqr (in float: n) is
return 1.0 / n**2;
const proc: main is func
local
var integer: i is 0;
var float: sum is 0.0;
begin
for i range 1 to 1000 do
sum +:= invsqr(flt(i));
end for;
writeln(sum digits 6 lpad 8);
end func;</lang>
=={{header|Slate}}==
|