Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Executable-library/REXX/executable-library-2.rexx
Normal file
16
Task/Executable-library/REXX/executable-library-2.rexx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*REXX pgm tests a number and a range for hailstone (Collatz) sequences.*/
|
||||
parse arg x .; if x=='' then x=27 /*get the optional first argument*/
|
||||
|
||||
$=hailstone(x) /*═════════════task 2════════════*/
|
||||
#=words($) /*number of numbers in sequence. */
|
||||
say x 'has a hailstone sequence of' # 'and starts with: ' subword($,1,4),
|
||||
' and ends with:' subword($,#-3)
|
||||
say
|
||||
w=0; do j=1 for 99999 /*═════════════task 3════════════*/
|
||||
$=hailstone(j); #=words($) /*obtain the hailstone sequence. */
|
||||
if #<=w then iterate /*Not big 'nuff? Then keep going.*/
|
||||
bigJ=j; w=# /*remember what # has biggest HS.*/
|
||||
end /*j*/
|
||||
|
||||
say '(between 1──►99,999) ' bigJ 'has the longest hailstone sequence:' w
|
||||
/*stick a fork in it, we're done.*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue