31 lines
591 B
Text
31 lines
591 B
Text
#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
|