Jump to content

Primes with digits in nondecreasing order: Difference between revisions

→‎{{header|ALGOL 68}}: Use ALGOL 68-primes
(Added Sidef)
(→‎{{header|ALGOL 68}}: Use ALGOL 68-primes)
Line 10:
INT max number = 1000;
# sieve the primes to max number #
PR read "primes.incl.a68" PR
[ 1 : max number ]BOOL prime;
prime[ 1 ] := FALSE;BOOL prime[ 2= ]PRIMESIEVE :=max TRUEnumber;
FOR i FROM 3 BY 2 TO max number DO prime[ i ] := TRUE OD;
FOR i FROM 4 BY 2 TO max number DO prime[ i ] := FALSE OD;
FOR i FROM 3 BY 2 TO ENTIER sqrt( max number ) DO
IF prime[ i ] THEN
FOR s FROM i * i BY i + i TO max number DO prime[ s ] := FALSE OD
FI
OD;
# we can easily generate candidate numbers with a few nested loops #
INT p count := 0;
Line 61 ⟶ 54:
Found 50 non-descending primes up to 1000
</pre>
 
=={{header|APL}}==
{{works with|Dyalog APL}}
3,044

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.