Anonymous user
Primes with digits in nondecreasing order: Difference between revisions
Primes with digits in nondecreasing order (view source)
Revision as of 15:58, 7 June 2021
, 2 years ago→{{header|REXX}}: used simpler coding, used a better grid.
Drkameleon (talk | contribs) (Added Arturo implementation) |
m (→{{header|REXX}}: used simpler coding, used a better grid.) |
||
Line 649:
=={{header|REXX}}==
<lang rexx>/*REXX program finds & displays primes whose decimal digits are in non─decreasing order.*/
parse arg
if
if cols=='' | cols=="," then cols= 10 /* " " " " " " */
call genP /*build array of semaphores for primes.*/
w= 10 /*width of a number in any column. */
'
if cols>0 then say ' index │'center(
if cols>0 then say '───────┼'center(""
$= /*a list of non─decreasing digit primes*/
do j=1 while @.j<
do k=1 for length(p)-1 /*validate that it meets specifications*/
if substr(p, k, 1) > substr(p, k+1, 1) then iterate j /*compare dig with next.*/
end /*k*/
if cols
say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
idx= idx + cols /*bump the index count for the output*/
Line 674 ⟶ 673:
if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible display residual output.*/
if cols>0 then say '───────┴'center("" , 1 + cols*(w+1), '─') /*display foot sep. */
say
say 'Found ' commas(
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 683:
#= 3; s.#= @.# **2 /*number of primes so far; prime². */
/* [↓] generate more primes ≤ high.*/
do j=@.#+2 by 2 to
parse var j '' -1 _; if _==5 then iterate /*J divisible by 5? (right dig)*/
if j// 3==0 then iterate /*" " " 3? */
Line 694:
{{out|output|text= when using the default inputs:}}
<pre>
index │ primes whose decimal digits are in non─decreasing order,
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │
11 │
21 │
31 │
41 │
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────
Found 50 primes whose decimal digits are in non─decreasing order,
</pre>
|