Loops/While: Difference between revisions

1,217 bytes added ,  2 months ago
m
added output
No edit summary
m (added output)
 
(9 intermediate revisions by 8 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 1,009 ⟶ 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,527 ⟶ 1,572:
 
=={{header|Elena}}==
ELENA 46.x:
<syntaxhighlight lang="elena">public program()
{
Line 1,533 ⟶ 1,578:
while (i > 0)
{
console.writeLine:(i);
i /= 2
Line 1,555 ⟶ 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,843 ⟶ 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,088 ⟶ 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,110 ⟶ 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,192 ⟶ 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,676 ⟶ 3,774:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var i = 1024
while (i > 0) {
System.print(i)
57

edits