Loops/With multiple ranges: Difference between revisions

Content added Content deleted
(Fix output in Nim solution)
(Added 11l)
Line 91: Line 91:
*   [[Loops/Wrong ranges]]
*   [[Loops/Wrong ranges]]
<br><br>
<br><br>
=={{header|11l}}==
{{trans|Nim}}

<lang 11l>V prod = 1
V s = 0

-V
x = +5
y = -5
z = -2
one = 1
three = 3
seven = 7

F body(j)
:s += abs(j)
I abs(:prod) < 2 ^ 27 & j != 0
:prod *= j

L(j) (-three .. 3 ^ 3).step(three) {body(j)}
L(j) (-seven .. seven).step(x) {body(j)}
L(j) 555 .. 550 - y {body(j)}
L(j) (22 .. -28).step(-three) {body(j)}
L(j) 1927 .. 1939 {body(j)}
L(j) (x .. y).step(z) {body(j)}
L(j) 11 ^ x .. 11 ^ x + one {body(j)}

V ss = String(s)
V ps = String(prod)
V m = max(ss.len, ps.len)
print(‘ sum = ’ss.rjust(m))
print(‘prod = ’ps.rjust(m))</lang>

{{out}}
<pre>
sum = 348173
prod = -793618560
</pre>

=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
{{works with|as|Raspberry Pi 3B version Buster 64 bits}}
Line 299: Line 338:
-793618560
-793618560
</pre>
</pre>

=={{header|ALGOL 60}}==
=={{header|ALGOL 60}}==
{{works with|MARST}}
{{works with|MARST}}