Loops/While: Difference between revisions

m
→‎version 2: added version 3, also added comments in header section for version 2. -- ~~~~
m (More spaces. Less tabs. My fault.)
m (→‎version 2: added version 3, also added comments in header section for version 2. -- ~~~~)
Line 877:
1
</pre>
===version 2, right justified===
Note that a faster version could be implemented with
<lang rexx>/*REXX program to show a DO WHILE construct. */
<br> '''DO WHILE x\==0'''
<br>but that isn't compliant with the wording of the task.
<lang rexx>/*REXX program to show a DO WHILE construct. */
x=1024
do while x>0
 
say right(x,10)
do while x>0
x=x%2 x=x%2 /*in REXX, % is integer division. */
say right(x,10)
end</lang>
x=x%2 /*in REXX, % is integer division. */
end</lang>
'''output'''
<pre style="height:30ex;overflow:scroll">
Line 899 ⟶ 901:
1
</pre>
===version 3, faster WHILE comparison===
<lang rexx>/*REXX program to show a DO WHILE construct. */
x=1024
do while x>>0 /*this is an exact comparison. */
say right(x,10)
x=x%2 /*in REXX, % is integer division. */
end</lang>
'''output''' is the same as version 2.
<br><br>
 
=={{header|Ruby}}==