Anonymous user
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
parse arg N count bot top triples . /*obtain optional
if N=='' then N=25 /*Not specified?
if count=='' then count=1000 /* " " " " " " */
if bot=='' then bot=2000 /* " " " " " " */
if top=='' then top=2005 /* " " " " " " */
if triples=='' then triples=250-1 /* " " " " " " */
say 'The first '
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: procedure; parse arg m 1 mm,h; am=abs(m); if h\=='' then am=h
$=1 2; @= /*$
do j=3 by 2 to am * max(1, 15
@=@ j /* [↓] construct a ludic sequence. */
end /*j*/ /* [↑] high limit: approx
@=@' '
@=changestr(' 'word(@,d)" ",@, ' . ') /*delete the number in the sequence. */
@=space(@) /*remove extra blanks from the list. */
if h=='' then return subword($,1,am)
return subword($,m,h-m+1) /*return a section of a range. */</lang>
Some older REXXes don't have a '''changestr'''
<br><br>
'''output''' using the
<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
|