CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
9
Task/Executable-library/REXX/executable-library-1.rexx
Normal file
9
Task/Executable-library/REXX/executable-library-1.rexx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/*REXX program returns the hailstone (Collatz) sequence for any integer.*/
|
||||
numeric digits 20 /*ensure enough digits for mult. */
|
||||
parse arg n 1 s /*N & S assigned to the first arg*/
|
||||
do while n\==1 /*loop while N isn't unity. */
|
||||
if n//2 then n=n*3+1 /*if N is odd, calc: 3*n +1 */
|
||||
else n=n%2 /* " " " even, perform fast ÷ */
|
||||
s=s n /*build a sequence list (append).*/
|
||||
end /*while*/
|
||||
return s
|
||||
Loading…
Add table
Add a link
Reference in a new issue