Ludic numbers: Difference between revisions

m
→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (added whitespace before the TOC (table of contents), used a constant uncapitalized spelling of ludic.)
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.)
Line 2,120:
 
=={{header|REXX}}==
<lang rexx>/*REXX program to displaydisplays (a range of) ludic numbers, or a count of samewhen a range is used.*/
parse arg N count bot top triples . /*obtain optional parameters/argsarguments from the CL*/
if N=='' then N=25 /*Not specified? Use Then use the default.*/
if count=='' then count=1000 /* " " " " " " */
if bot=='' then bot=2000 /* " " " " " " */
if top=='' then top=2005 /* " " " " " " */
if triples=='' then triples=250-1 /* " " " " " " */
say 'The first ' N " ludic numbers: " ludic(n) /*display title for what's coming next.*/
say
say "There are " words(ludic(-count)) ' ludic numbers from 1───►'count " (inclusive)."
say
say "The " bot ' to ' top " ludic numbers are: " ludic(bot,top)
Line 2,136:
do j=1 for words($); _=word($,j) /*it is known that ludic _ exists*/
if wordpos(_+2,$)==0 | wordpos(_+6,$)==0 then iterate /*¬triple.*/
#=#+1; @=@ '◄'_ _+2 _+6"► " /*bump triple counter, and ··· */
end /*j*/ /* [↑] append the found triple ──► @ */
 
if @=='' then say 'From 1──►'triples", no triples found."
else say 'From 1──►'triples", " # ' triples found:' @
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────LUDIC subroutine────────────────────*/
ludic: procedure; parse arg m 1 mm,h; am=abs(m); if h\=='' then am=h
$=1 2; @= /*$=ludic≡ludic #snumbers superset,; @=# series@≡sequence*/
do j=3 by 2 to am * max(1, 15 /* [↓]((m>0) | constructh\=='') a ludic series.*/)
@=@ j /* [↓] construct a ludic sequence. */
do j=3 by 2 to am * max(1,15*((m>0)|h\=='')); @=@ j; end; @=@' '
end /*j*/ /* [↑] high limit: approx| or exact. */
@=@' ' do while words(@)\==0 /*append [↓]a blank examineto the first word. number sequence*/
f=word(@,1); do $while words(@)\==$0 f /*append this[↓] examine the first word. to list.*/
do df=word(@,1); by f while d< $=words(@)$ f /*useappend 1stthis #,first word to the elidelist. all occurances*/
@ do d=changestr('1 'word by f while d<=words(@,d)" ",@, ' . ') /*deleteuse the1st number, #elide inall theoccurances seq#*/
@=changestr(' 'word(@,d)" ",@, ' . ') /*delete the number in the sequence. */
end /*d*/ /* [↑] done eliding "1st" number*/
@=translate(@,,.) end /*d*/ /*translate periods[↑] to blanks.done eliding the "1st" number. */
end @=translate(@, , .) /*forever*/ /* [↑] done eliding ludic #s. /*translate periods (dots) to blanks. */
@=space(@) end /*while*/ /*remove extra[↑] blanks fromdone listeliding ludic numbers. */
 
@=space(@) /*remove extra blanks from the list. */
if h=='' then return subword($,1,am) /*return a range of ludic numbers*/
if h=='' then return subword($,1,am) return subword($,m,h-m+1) /*return a section range of a rangeludic numbers. */</lang>
return subword($,m,h-m+1) /*return a section of a range. */</lang>
Some older REXXes don't have a &nbsp; '''changestr''' bif&nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[CHANGESTR.REX]].
<br><br>
'''output''' &nbsp; using the defaultsdefault values for input:
<pre>
The first 25 ludic numbers: 1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107