Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 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