Loops/While: Difference between revisions

1,478 bytes added ,  2 months ago
m
added output
(Added Z80 Assembly version)
m (added output)
 
(12 intermediate revisions by 10 users not shown)
Line 312:
end;
end</syntaxhighlight>
 
=={{header|Amazing Hopper}}==
<syntaxhighlight lang="c">
#include <jambo.h>
 
Main
i=1024
Loop
Printnl 'i'
i \= 2
Back if 'i' is positive
End
</syntaxhighlight>
<p>Assembler Hopper code:</p>
<syntaxhighlight lang="amazing hopper">
main:
i=1024
____CODE_JUMP____883612951:,
{i};{"\n"}print;
i\=2
{i},jpos(____CODE_JUMP____883612951),____CODE_JUMP____854411479:,
emptystack?do{{0}};return
</syntaxhighlight>
{{out}}
<pre>
1024
512
256
128
64
32
16
8
4
2
1
</pre>
 
=={{header|AmbientTalk}}==
Line 595 ⟶ 632:
A/2→A
End</syntaxhighlight>
 
=={{header|Bait}}==
<syntaxhighlight lang="bait">
fun main() {
mut i := 1024
for i > 0 {
println(i)
i = i / 2
}
}
</syntaxhighlight>
 
=={{header|BASIC}}==
Line 998 ⟶ 1,046:
40 LET I=INT (I/2)
50 GOTO 20</syntaxhighlight>
 
==={{header|SmallBASIC}}===
<syntaxhighlight lang="qbasic">
i = 1024
WHILE i > 0
PRINT i
i = i \ 2 ' Using \ for integer division instead of /
WEND</syntaxhighlight>
 
==={{header|TI-83 BASIC}}===
Line 1,516 ⟶ 1,572:
 
=={{header|Elena}}==
ELENA 46.x:
<syntaxhighlight lang="elena">public program()
{
Line 1,522 ⟶ 1,578:
while (i > 0)
{
console.writeLine:(i);
i /= 2
Line 1,544 ⟶ 1,600:
(message "%d" i)
(setq i (/ i 2))))</syntaxhighlight>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
int i = 1024
while i > 0
writeLine(i)
i /= 2
end
</syntaxhighlight>
 
=={{header|Erlang}}==
Line 1,832 ⟶ 1,897:
say "[N][line break]";
let N be N / 2;</syntaxhighlight>
 
=={{Header|Insitux}}==
 
Use <code>/</code> for floating-point division, and use <code>(> i 0)</code> for full printing of the sequence (as the output of <code>1</code> here is due to the return of the last <code>while</code> statement).
 
<syntaxhighlight lang="insitux">
(var i 1024)
 
(while (> i 1)
(print i)
(var i (// i 2)))
</syntaxhighlight>
 
{{out}}
 
<pre>
1024
512
256
128
64
32
16
8
4
2
1
</pre>
 
=={{header|J}}==
Line 2,077 ⟶ 2,170:
 
=={{header|langur}}==
0.8 changed the keyword for a test only loop from for to while.
 
{{works with|langur|0.8}}
<syntaxhighlight lang="langur">var .i = 1024
while .i > 0 {
writeln .i
.i \= 2
}</syntaxhighlight>
 
{{works with|langur|< 0.8}}
<syntaxhighlight lang="langur">var .i = 1024
for .i > 0 {
writeln .i
.i \= 2
Line 2,099 ⟶ 2,182:
#i /= 2
^}</syntaxhighlight>
 
=={{header|LDPL}}==
<syntaxhighlight lang="ldpl">data:
n is number
 
procedure:
store 1024 in n
while n is greater than 0 do
display n lf
divide n by 2 in n
floor n
repeat</syntaxhighlight>
 
=={{header|LIL}}==
Line 3,055 ⟶ 3,150:
Put the sky over the table into the sky.
(Rockstar is known for doing that JavaScript quirk, since all numbers are floats, but due to it having the same limits as JavaScript and the most popular interpreter being JS-based, the loop is finite, yet you don't get the result you would get in something like Python.)</syntaxhighlight>
=={{header|RPL}}==
≪ 1024
'''WHILE''' DUP '''REPEAT'''
DUP 1 DISP
2 /
'''END'''
DROP
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">i = 1024
Line 3,172 ⟶ 3,276:
end while;
end func;</syntaxhighlight>
{{out}}
<pre>
1024
512
256
128
64
32
16
8
4
2
1
</pre>
 
=={{header|SenseTalk}}==
Line 3,656 ⟶ 3,774:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var i = 1024
while (i > 0) {
System.print(i)
57

edits