Primes with digits in nondecreasing order: Difference between revisions

Added solution for Action!
No edit summary
(Added solution for Action!)
Line 5:
Find all primes   ('''n''')   with their decimal digits in non-decreasing order,   where   '''n   <   1,000'''
<br><br>
 
=={{header|Action!}}==
{{libheader|Action! Sieve of Eratosthenes}}
<lang Action!>INCLUDE "H6:SIEVE.ACT"
 
BYTE FUNC NonDecreasingDigits(INT x)
BYTE c,d,last
 
c=0 last=9
WHILE x#0
DO
d=x MOD 10
IF d>last THEN
RETURN (0)
FI
last=d
x==/10
OD
RETURN (1)
 
PROC Main()
DEFINE MAX="999"
BYTE ARRAY primes(MAX+1)
INT i,count=[0]
 
Put(125) PutE() ;clear the screen
Sieve(primes,MAX+1)
FOR i=2 TO MAX
DO
IF primes(i)=1 AND NonDecreasingDigits(i)=1 THEN
PrintI(i) Put(32)
count==+1
FI
OD
PrintF("%E%EThere are %I primes",count)
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Primes_with_digits_in_nondecreasing_order.png Screenshot from Atari 8-bit computer]
<pre>
2 3 5 7 11 13 17 19 23 29 37 47 59 67 79 89 113 127 137 139 149 157 167 179 199 223 227 229
233 239 257 269 277 337 347 349 359 367 379 389 449 457 467 479 499 557 569 577 599 677
 
There are 50 primes
</pre>
 
=={{header|ALGOL 68}}==
Anonymous user