Ludic numbers: Difference between revisions
Content deleted Content added
Redherring (talk | contribs) |
m →{{header|REXX}}: added/changed comments and whitespace. |
||
Line 3,319:
=={{header|REXX}}==
<lang rexx>/*REXX program
parse arg N count bot top triples . /*obtain optional arguments from the CL*/
if N=='' | N=="," then N=
if count=='' | count=="," then count=
if bot=='' | bot=="," then bot=
if top=='' | top=="," then top=
if triples=='' | triples=="," then triples=
say 'The first ' N " ludic numbers:
do j=1 until word($, j) > count /*search up to a specific #.*/
end /*j*/
say
say "There are " j - 1 ' ludic numbers that are ≤ ' count
say
say "The " bot '───►' top ' (inclusive) ludic numbers are: ' subword($, bot)
@= /*list of ludic triples found (so far).*/
_= word($, j) /*it is known that ludic _ exists. */
if _>=triples then leave /*only process up to a specific number.*/
if wordpos(_+2, $)==0
#= # + 1
end /*j*/
say
if @=='' then say 'From 1──►'triples", no triples found."
Line 3,344 ⟶ 3,348:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
ludic: procedure; parse arg m,,@; $= 1 2
end /*j*/
@= @' ';
do while n\==0;
$= $ f
do d=1 by
@=
@= translate(@, , .) /*change dots to blanks; count numbers.*/
end /*while*/ /* [↑] done eliding ludic numbers. */
return subword($, 1, m) /*return a range of ludic numbers. */</lang>
Some older REXXes don't have a '''changestr''' BIF, so one is included here ──► [[CHANGESTR.REX]].
|