Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -1,6 +1,6 @@
BEGIN # find all primes with strictly decreasing digits #
PR read "primes.incl.a68" PR # include prime utilities #
PR read "rows.incl.a68" PR # include array utilities #
PR read "sort.incl.a68" PR # include sort utilities #
[ 1 : 512 ]INT primes; # there will be at most 512 (2^9) primes #
INT p count := 0; # number of primes found so far #
FOR d1 FROM 0 TO 1 DO
@ -23,7 +23,7 @@ BEGIN # find all primes with strictly decreasing digits #
INT n9 = IF d9 = 1 THEN ( n8 * 10 ) + 1 ELSE n8 FI;
IF n9 > 0 THEN
IF is probably prime( n9 ) THEN
# have a prime with strictly descending digits #
# have a prime with strictly decreasing digits #
primes[ p count +:= 1 ] := n9
FI
FI
@ -36,9 +36,8 @@ BEGIN # find all primes with strictly decreasing digits #
OD
OD
OD;
QUICKSORT primes FROMELEMENT 1 TOELEMENT p count; # sort the primes #
# display the primes #
FOR i TO p count DO
primes QUICKSORT ELEMENTS( 1, p count ); # sort the primes #
FOR i TO p count DO # display the primes #
print( ( " ", whole( primes[ i ], -8 ) ) );
IF i MOD 10 = 0 THEN print( ( newline ) ) FI
OD

View file

@ -0,0 +1,13 @@
##
uses School;
function DescendingSeq(n: integer): sequence of integer;
begin
if n = 0 then
for var x := 9 downto 1 do
yield sequence DescendingSeq(x) + x
else for var x := n*10 + n mod 10 - 1 downto n*10 + 1 do
yield sequence DescendingSeq(x) + x;
end;
DescendingSeq(0).Order.Where(n -> n.IsPrime).Print;