Jump to content

Loops/While: Difference between revisions

→‎version 2, right justified: removed this inappropriate entry (bad joke))
(→‎Version 1, fastest: removed this inappropriate entry (bad joke))
(→‎version 2, right justified: removed this inappropriate entry (bad joke)))
Line 1,103:
2
1
</pre>
 
===version 2, right justified===
Note that a faster version could be implemented with
<br>
::::: '''DO WHILE x\==0'''
but that wouldn't be compliant with the wording of the task.
<lang rexx>/*REXX program demonstrates a DO WHILE with index reduction construct.*/
x=1024 /*define the initial value of X.*/
do while x>0 /*test if made at the top of DO.*/
say right(x,10) /*pretty output by aligning right*/
x=x%2 /*in REXX, % is integer division.*/
end
/*stick a fork in it, we're done.*/</lang>
'''output'''
<pre style="overflow:scroll">
1024
512
256
128
64
32
16
8
4
2
1
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.