Generate and show all primes with strictly descending decimal digits.

See also
 OEIS:A052014 - Primes with distinct digits in descending order
Related

Ascending primes


include xpllib;         \provides IsPrime and Sort
 
int I, N, Mask, Digit, A(512), Cnt;
[for I:= 0 to 511 do
    [N:= 0;  Mask:= I;  Digit:= 9;
    while Mask do
        [if Mask&1 then 
            N:= N*10 + Digit;
        Mask:= Mask>>1;
        Digit:= Digit-1;
        ];
    A(I):= N;
    ];
Sort(A, 512);
Cnt:= 0;
Format(9, 0);
for I:= 1 to 511 do     \skip empty set
    [N:= A(I);
    if IsPrime(N) then
        [RlOut(0, float(N));
        Cnt:= Cnt+1;
        if rem(Cnt/10) = 0 then CrLf(0);
        ];
    ];
]