Anonymous user
Loops/While: Difference between revisions
→{{header|REXX}}: corrected the messed up deletion and modification of two REXX versions, added program comments and re-installed the various REXX section comments. -- ~~~~
(→{{header|REXX}}: corrected the messed up deletion and modification of two REXX versions, added program comments and re-installed the various REXX section comments. -- ~~~~) |
|||
Line 1,082:
=={{header|REXX}}==
===Version 1, right justified===▼
j=1024 /*define the initial value of j.*/
do while j>0 /*test if made at the top of do.*/
j=j%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/</lang>
<pre style="height:30ex;overflow:scroll">
512
256
128
64
32
16
8
4
2
1
</pre>
Note that a faster version could be implemented with
<br>::::: '''DO WHILE x\==0'''
<br>but that isn't compliant with the wording of the task.
<lang rexx>/*REXX program
x=1024 /*define the initial value of x.*/
▲x=1024
/*stick a fork in it, we're done.*/</lang>
▲{{output}}
'''output'''
<pre style="height:30ex;overflow:scroll">
1024
512
256
128
64
32
16
8
4
2
1
</pre>
===Version
▲<lang rexx>/*REXX program to show a DO WHILE construct. */
<lang rexx>/*REXX program demonstrates a DO WHILE construct. */
x=1024
do while
say right(x
x=x%2 /*in REXX, % is integer division.*/
▲ end</lang>
end
'''output''' is the same as version 1.▼
/*stick a fork in it, we're done.*/</lang>
<br><br>
=={{header|Ruby}}==
|