Sum multiples of 3 and 5: Difference between revisions

Initial implementation in PL/I
(Updated D entry)
(Initial implementation in PL/I)
Line 1,280:
2333333333333333333333333333316666666666666666666666666668
233333333333333333333333333333166666666666666666666666666668</pre>
 
=={{header|PL/I}}==
<lang PL/I>threeor5: procedure options (main); /* 8 June 2014 */
declare (i, n) fixed(10), sum fixed (31) static initial (0);
 
get (n);
put ('The number of multiples of 3 or 5 below ' || trim(n) || ' is');
 
do i = 1 to n-1;
if mod(i, 3) = 0 | mod(i, 5) = 0 then sum = sum + i;
end;
 
put edit ( trim(sum) ) (A);
 
end threeor5;</lang>
Outputs:
<pre>
The number of multiples of 3 or 5 below 1000 is 233168
The number of multiples of 3 or 5 below 10000 is 23331668
The number of multiples of 3 or 5 below 100000 is 2333316668
The number of multiples of 3 or 5 below 1000000 is 233333166668
The number of multiples of 3 or 5 below 10000000 is 23333331666668
The number of multiples of 3 or 5 below 100000000 is 2333333316666668</pre>
 
=={{header|PowerShell}}==