Sum multiples of 3 and 5: Difference between revisions

Add Seed7 example
(Add Seed7 example)
Line 711:
 
Output:
<pre>
233168
2333333333333333333316666666666666666668
</pre>
 
=={{header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
include "bigint.s7i";
 
const func bigInteger: sum35 (in bigInteger: n) is func
result
var bigInteger: sum35 is 0_;
local
const func bigInteger: sumMul (in bigInteger: n, in bigInteger: f) is func
result
var bigInteger: sumMul is 0_;
local
var bigInteger: n1 is 0_;
begin
n1 := pred(n) div f;
sumMul := f * n1 * succ(n1) div 2_;
end func;
begin
sum35 := sumMul(n, 3_) + sumMul(n, 5_) - sumMul(n, 15_);
end func;
const proc: main is func
begin
writeln(sum35(1000_));
writeln(sum35(10_ ** 20));
end func;</lang>
 
{{out}}
<pre>
233168