How to resolve the algorithm Descending primes step by step in the FreeBASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Descending primes step by step in the FreeBASIC programming language
Table of Contents
Problem Statement
Generate and show all primes with strictly descending decimal digits.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Descending primes step by step in the FreeBASIC programming language
Source code in the freebasic programming language
#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
You may also check:How to resolve the algorithm Literals/String step by step in the MIPS Assembly programming language
You may also check:How to resolve the algorithm Sorting algorithms/Counting sort step by step in the Wren programming language
You may also check:How to resolve the algorithm Show ASCII table step by step in the Jsish programming language
You may also check:How to resolve the algorithm Generate lower case ASCII alphabet step by step in the Groovy programming language
You may also check:How to resolve the algorithm Generate random chess position step by step in the J programming language