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 "isprime.bas"
#include "sort.bas"
 
Dim As Double t0 = Timer
Dim As Integer i, n, tmp, num, cant
Dim Shared As Integer matriz(512)
For i = 0 To 511
    n = 0
    tmp = i
    num = 9
    While tmp
        If tmp And 1 Then n = n * 10 + num
        tmp = tmp Shr 1
        num -= 1
    Wend
    matriz(i) = n
Next i
 
Sort(matriz())
 
cant = 0
For i = 1 To Ubound(matriz)-1
    n = matriz(i)
    If IsPrime(n) Then
        Print Using "#########"; n;
        cant += 1
        If cant Mod 10 = 0 Then Print
    End If
Next i
Print Using !"\n\nThere are & descending primes."; cant
Sleep